cupertino_tab_bar.0.dart 1.65 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 [CupertinoTabBar].

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

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

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

23
class CupertinoTabBarExample extends StatelessWidget {
24
  const CupertinoTabBarExample({super.key});
25 26 27 28 29 30 31

  @override
  Widget build(BuildContext context) {
    return CupertinoTabScaffold(
      tabBar: CupertinoTabBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
32
            icon: Icon(CupertinoIcons.star_fill),
33
            label: 'Favorites',
34 35 36 37 38 39 40 41
          ),
          BottomNavigationBarItem(
            icon: Icon(CupertinoIcons.clock_solid),
            label: 'Recents',
          ),
          BottomNavigationBarItem(
            icon: Icon(CupertinoIcons.person_alt_circle_fill),
            label: 'Contacts',
42 43
          ),
          BottomNavigationBarItem(
44 45
            icon: Icon(CupertinoIcons.circle_grid_3x3_fill),
            label: 'Keypad',
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
          ),
        ],
      ),
      tabBuilder: (BuildContext context, int index) {
        return CupertinoTabView(
          builder: (BuildContext context) {
            return Center(
              child: Text('Content of tab $index'),
            );
          },
        );
      },
    );
  }
}