Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (45 sloc) 1.75 KB
import 'package:adaptive_bottom_nav_sample/custom/bottom_navigation_tab.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
class CupertinoBottomNavigationScaffold extends StatelessWidget {
const CupertinoBottomNavigationScaffold({
@required this.navigationBarItems,
@required this.onItemSelected,
@required this.selectedIndex,
Key key,
}) : assert(navigationBarItems != null),
assert(onItemSelected != null),
assert(selectedIndex != null),
super(key: key);
/// List of the tabs to be displayed with their respective navigator's keys.
final List<BottomNavigationTab> navigationBarItems;
/// Called when a tab selection occurs.
final ValueChanged<int> onItemSelected;
final int selectedIndex;
Widget build(BuildContext context) => CupertinoTabScaffold(
// As we're managing the selected index outside, there's no need
// to make this Widget stateful. We just need pass the selectedIndex to
// the controller every time the widget is rebuilt.
controller: CupertinoTabController(initialIndex: selectedIndex),
tabBar: CupertinoTabBar(
items: navigationBarItems
(item) => item.bottomNavigationBarItem,
onTap: onItemSelected,
tabBuilder: (context, index) {
final barItem = navigationBarItems[index];
return CupertinoTabView(
navigatorKey: barItem.navigatorKey,
onGenerateRoute: (settings) => CupertinoPageRoute(
settings: settings,
builder: barItem.initialPageBuilder,
You can’t perform that action at this time.