-
-
Save ijoschek/2eefe68dd03ff79c93ab74513a64ca17 to your computer and use it in GitHub Desktop.
flutter_nav_tut
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_tut_navigation/content.dart'; | |
import 'package:flutter_tut_navigation/newPage.dart'; | |
void main() => runApp(Main()); | |
class Main extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Navigation Tutorial', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MainPage(), | |
// Here will be some code | |
); | |
} | |
} | |
class MainPage extends StatefulWidget { | |
@override | |
_MainPageState createState() => _MainPageState(); | |
} | |
class _MainPageState extends State<MainPage> { | |
int _currentIndex = 0; | |
final List<Widget> _children = [ | |
ContentPage(title: "Home Page"), | |
ContentPage(title: "Messages Page"), | |
ContentPage(title: "Profile Page") | |
]; | |
void _onBottomNavBarTab(int index) { | |
setState(() { | |
_currentIndex = index; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Flutter Navigation Tutorial"), | |
), | |
body: _children[_currentIndex], | |
bottomNavigationBar: BottomNavigationBar( | |
currentIndex: _currentIndex, | |
onTap: _onBottomNavBarTab, | |
items: [ | |
BottomNavigationBarItem( | |
icon: Icon(Icons.home), | |
title: Text('Home'), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.mail), | |
title: Text('Messages'), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.person), | |
title: Text('Profile'), | |
) | |
], | |
), | |
drawer: Drawer( | |
child: ListView( | |
children: <Widget>[ | |
UserAccountsDrawerHeader( | |
accountName: Text('Max'), accountEmail: Text('max@email.com')), | |
// Here will be some code | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment