| // 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. |
| |
| /// Flutter code sample for [CupertinoTabScaffold]. |
| |
| import 'package:flutter/cupertino.dart'; |
| |
| void main() => runApp(const TabScaffoldApp()); |
| |
| class TabScaffoldApp extends StatelessWidget { |
| const TabScaffoldApp({super.key}); |
| |
| @override |
| Widget build(BuildContext context) { |
| return const CupertinoApp( |
| theme: CupertinoThemeData(brightness: Brightness.light), |
| home: TabScaffoldExample(), |
| ); |
| } |
| } |
| |
| class TabScaffoldExample extends StatefulWidget { |
| const TabScaffoldExample({super.key}); |
| |
| @override |
| State<TabScaffoldExample> createState() => _TabScaffoldExampleState(); |
| } |
| |
| class _TabScaffoldExampleState extends State<TabScaffoldExample> { |
| @override |
| Widget build(BuildContext context) { |
| return CupertinoTabScaffold( |
| tabBar: CupertinoTabBar( |
| items: const <BottomNavigationBarItem>[ |
| BottomNavigationBarItem( |
| icon: Icon(CupertinoIcons.home), |
| label: 'Home', |
| ), |
| BottomNavigationBarItem( |
| icon: Icon(CupertinoIcons.search_circle_fill), |
| label: 'Explore', |
| ), |
| ], |
| ), |
| tabBuilder: (BuildContext context, int index) { |
| return CupertinoTabView( |
| builder: (BuildContext context) { |
| return CupertinoPageScaffold( |
| navigationBar: CupertinoNavigationBar( |
| middle: Text('Page 1 of tab $index'), |
| ), |
| child: Center( |
| child: CupertinoButton( |
| child: const Text('Next page'), |
| onPressed: () { |
| Navigator.of(context).push( |
| CupertinoPageRoute<void>( |
| builder: (BuildContext context) { |
| return CupertinoPageScaffold( |
| navigationBar: CupertinoNavigationBar( |
| middle: Text('Page 2 of tab $index'), |
| ), |
| child: Center( |
| child: CupertinoButton( |
| child: const Text('Back'), |
| onPressed: () { |
| Navigator.of(context).pop(); |
| }, |
| ), |
| ), |
| ); |
| }, |
| ), |
| ); |
| }, |
| ), |
| ), |
| ); |
| }, |
| ); |
| }, |
| ); |
| } |
| } |