mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-11-08 12:39:17 +00:00
updated: navigation_drawer example with better implementation
This commit is contained in:
@@ -7,14 +7,24 @@ void main() {
|
|||||||
class MyDrawerApp extends StatelessWidget {
|
class MyDrawerApp extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
ListView listView = new ListView(
|
var headerChild = new DrawerHeader(child: new Text("Header"));
|
||||||
children: <Widget>[
|
var aboutChild = new AboutListTile(
|
||||||
getPaddedFirstText("Nav Item 1"),
|
child: new Text("About"),
|
||||||
getPaddedText("Nav Item 2"),
|
applicationName: "Application Name",
|
||||||
getPaddedText("Nav Item 3"),
|
applicationVersion: "v1.0.0",
|
||||||
getPaddedText("Nav Item 4"),
|
applicationIcon: new Icon(Icons.adb),
|
||||||
],
|
icon: new Icon(Icons.info));
|
||||||
);
|
|
||||||
|
var myNavChildren = [
|
||||||
|
headerChild,
|
||||||
|
getNavItem(Icons.settings, "Settings"),
|
||||||
|
getNavItem(Icons.call, "Call"),
|
||||||
|
getNavItem(Icons.home, "Home"),
|
||||||
|
getNavItem(Icons.account_box, "Account"),
|
||||||
|
aboutChild
|
||||||
|
];
|
||||||
|
|
||||||
|
ListView listView = new ListView(children: myNavChildren);
|
||||||
Drawer myDrawer = new Drawer(
|
Drawer myDrawer = new Drawer(
|
||||||
child: listView,
|
child: listView,
|
||||||
);
|
);
|
||||||
@@ -31,15 +41,10 @@ class MyDrawerApp extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Padding getPaddedFirstText(var data) {
|
ListTile getNavItem(var icon, String s) {
|
||||||
return new Padding(
|
return new ListTile(
|
||||||
child: new Text(data),
|
leading: new Icon(icon),
|
||||||
padding: const EdgeInsets.only(
|
title: new Text(s),
|
||||||
left: 15.0, right: 15.0, bottom: .0, top: 40.0));
|
);
|
||||||
}
|
|
||||||
|
|
||||||
Padding getPaddedText(var data) {
|
|
||||||
return new Padding(
|
|
||||||
child: new Text(data), padding: const EdgeInsets.all(15.0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user