Flutter Navigation Drawer Example





















main.dart
=========


import 'package:flutter/material.dart';
import 'package:akeepo/navdrawer.dart';
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {


@override Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,

),
home: NavDrawer(),

);
}
}



navdrawer.dart
================


import 'package:flutter/material.dart';

class NavDrawer extends StatefulWidget {
@override _NavDrawerState createState() => _NavDrawerState();
}

class _NavDrawerState extends State<NavDrawer> {
@override Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Nav Drawer")),
drawer: new Drawer(
child: new ListView(
children: <Widget>[
new UserAccountsDrawerHeader(
accountName: new Text("Pratap Kumar"),
accountEmail: new Text("kprathap23@gmail.com"),
decoration: new BoxDecoration(
image: new DecorationImage(
image: new ExactAssetImage('assets/images/lake.jpeg'),
fit: BoxFit.cover,
),
),
currentAccountPicture: CircleAvatar(
backgroundImage: NetworkImage(
"https://randomuser.me/api/portraits/men/46.jpg")),
),
new ListTile(
leading: Icon(Icons.library_music),
title: new Text("Music"),
onTap: () {
Navigator.pop(context);
}),
new ListTile(
leading: Icon(Icons.movie),
title: new Text("Movies"),
onTap: () {
Navigator.pop(context);
}),
new ListTile(
leading: Icon(Icons.shopping_cart),
title: new Text("Shopping"),
onTap: () {
Navigator.pop(context);
}),
new ListTile(
leading: Icon(Icons.apps),
title: new Text("Apps"),
onTap: () {
Navigator.pop(context);
}),
new ListTile(
leading: Icon(Icons.dashboard),
title: new Text("Docs"),
onTap: () {
Navigator.pop(context);
}),
new ListTile(
leading: Icon(Icons.settings),
title: new Text("Settings"),
onTap: () {
Navigator.pop(context);
}),
new Divider(),
new ListTile(
leading: Icon(Icons.info),
title: new Text("About"),
onTap: () {
Navigator.pop(context);
}),
new ListTile(
leading: Icon(Icons.power_settings_new),
title: new Text("Logout"),
onTap: () {
Navigator.pop(context);
}),
],
),
),
);
}
}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();

Armed Posts

Recent