Skip to content

Instantly share code, notes, and snippets.

@DaniyarGilimov
Last active June 22, 2019 10:17
Show Gist options
  • Save DaniyarGilimov/a90165b888d612d1e828cd73889ccf0f to your computer and use it in GitHub Desktop.
Save DaniyarGilimov/a90165b888d612d1e828cd73889ccf0f to your computer and use it in GitHub Desktop.
RootPage where located bottomNavigationBar
class RootPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _RootPage();
}
}
class _RootPage extends State<RootPage> {
int _currentIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: _tabs[context ,_currentIndex],
),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
onTap: (index) => setState(() => _currentIndex = index),
currentIndex: _currentIndex,
items: <BottomNavigationBarItem>[
//all BottomNavigationBarItem
],
),
);
}
}
Widget _tabs(BuildContext rootContext, int _tabIndex){
switch (_tabIndex) {
case 0:
return MainTabOrDetailPage(rootContext);
break;
case 1:
return OtherTab();
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment