| 1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import 'package:flutter/cupertino.dart'; |
| 6 | |
| 7 | /// Flutter code sample for [CupertinoTabBar]. |
| 8 | |
| 9 | void main() => runApp(const CupertinoTabBarApp()); |
| 10 | |
| 11 | class CupertinoTabBarApp extends StatelessWidget { |
| 12 | const CupertinoTabBarApp({super.key}); |
| 13 | |
| 14 | @override |
| 15 | Widget build(BuildContext context) { |
| 16 | return const CupertinoApp( |
| 17 | theme: CupertinoThemeData(brightness: Brightness.light), |
| 18 | home: CupertinoTabBarExample(), |
| 19 | ); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | class CupertinoTabBarExample extends StatelessWidget { |
| 24 | const CupertinoTabBarExample({super.key}); |
| 25 | |
| 26 | @override |
| 27 | Widget build(BuildContext context) { |
| 28 | return CupertinoTabScaffold( |
| 29 | tabBar: CupertinoTabBar( |
| 30 | items: const <BottomNavigationBarItem>[ |
| 31 | BottomNavigationBarItem(icon: Icon(CupertinoIcons.star_fill), label: 'Favorites' ), |
| 32 | BottomNavigationBarItem(icon: Icon(CupertinoIcons.clock_solid), label: 'Recents' ), |
| 33 | BottomNavigationBarItem( |
| 34 | icon: Icon(CupertinoIcons.person_alt_circle_fill), |
| 35 | label: 'Contacts' , |
| 36 | ), |
| 37 | BottomNavigationBarItem(icon: Icon(CupertinoIcons.circle_grid_3x3_fill), label: 'Keypad' ), |
| 38 | ], |
| 39 | ), |
| 40 | tabBuilder: (BuildContext context, int index) { |
| 41 | return CupertinoTabView( |
| 42 | builder: (BuildContext context) { |
| 43 | return Center(child: Text('Content of tab $index' )); |
| 44 | }, |
| 45 | ); |
| 46 | }, |
| 47 | ); |
| 48 | } |
| 49 | } |
| 50 | |