Last active
August 22, 2020 11:58
-
-
Save tredoe/3bbd5639815a98724e299455c9ea5b4e to your computer and use it in GitHub Desktop.
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'; | |
void main() { | |
runApp(Main()); | |
} | |
class Main extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData( | |
primarySwatch: Colors.lightGreen, | |
), | |
home: HomePage(NavMain()), | |
routes: <String, WidgetBuilder>{ | |
"/root": (BuildContext context) => HomePage(NavMain()), | |
"/foo": (BuildContext context) => HomePage(NavFoo()), | |
}, | |
); | |
} | |
} | |
class HomePage extends StatelessWidget { | |
final Widget drawer; | |
HomePage(this.drawer); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("App name"), | |
elevation: 15, | |
), | |
drawer: drawer, | |
body: Container( | |
child: Center( | |
child: Text("home page"), | |
), | |
), | |
); | |
} | |
} | |
class NavMain extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Drawer( | |
child: ListView( | |
children: [ | |
//DrawerHeader(child: null) | |
ListTile( | |
title: Text("One", | |
style: TextStyle( | |
fontSize: 32, | |
), | |
), | |
), | |
ListTile( | |
title: Text("Foo"), | |
//trailing: Icon(Icons.), | |
//onTap: () => PageDatabase(),// Navigator.of(context).pushNamed("/a"), | |
onTap: () { | |
Navigator.of(context).pop(); | |
Navigator.of(context).pushNamed("/foo"); | |
/*Navigator.of(context).push(MaterialPageRoute( | |
builder: (BuildContext context) => HomePage(NavDatabase()), | |
));*/ | |
}, | |
), | |
Divider(), | |
ListTile( | |
title: Text("Information"), | |
), | |
ListTile( | |
title: Text("Close"), | |
onTap: () => Navigator.of(context).pop(), | |
), | |
Container( | |
alignment: Alignment.bottomLeft, | |
child: ListTile( | |
title: Text("Back"), | |
onTap: () => Navigator.of(context).pushNamed("/root"), | |
), | |
), | |
], | |
), | |
); | |
} | |
} | |
class NavFoo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Drawer( | |
child: ListView( | |
children: [ | |
ListTile( | |
leading: Column( | |
children: [ | |
Text("Create"), | |
], | |
), | |
//title: Center(child: Text("Create")), | |
), | |
ListTile( | |
title: Text("Create some"), | |
), | |
Divider(thickness: 1.5), | |
ListTile( | |
title: Center(child: Text("Drop")), | |
), | |
ListTile( | |
title: Text("Drop some"), | |
), | |
ListTile( | |
title: Text("Back"), | |
onTap: () => Navigator.of(context).pushNamed("/root"), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment