cupertino_navigation_bar.0.dart 1.47 KB
Newer Older
1 2 3 4 5 6
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/cupertino.dart';

7 8
/// Flutter code sample for [CupertinoNavigationBar].

9
void main() => runApp(const NavBarApp());
10

11
class NavBarApp extends StatelessWidget {
12
  const NavBarApp({super.key});
13 14 15 16

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
17 18
      theme: CupertinoThemeData(brightness: Brightness.light),
      home: NavBarExample(),
19 20 21 22
    );
  }
}

23
class NavBarExample extends StatefulWidget {
24
  const NavBarExample({super.key});
25 26

  @override
27
  State<NavBarExample> createState() => _NavBarExampleState();
28 29
}

30
class _NavBarExampleState extends State<NavBarExample> {
31 32 33 34 35 36
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        // Try removing opacity to observe the lack of a blur effect and of sliding content.
        backgroundColor: CupertinoColors.systemGrey.withOpacity(0.5),
37
        middle: const Text('CupertinoNavigationBar Sample'),
38 39 40 41 42 43 44 45 46 47 48 49
      ),
      child: Column(
        children: <Widget>[
          Container(height: 50, color: CupertinoColors.systemRed),
          Container(height: 50, color: CupertinoColors.systemGreen),
          Container(height: 50, color: CupertinoColors.systemBlue),
          Container(height: 50, color: CupertinoColors.systemYellow),
        ],
      ),
    );
  }
}