Drawer App
main.dart
import 'package:flutter/material.dart';
import 'MyHomePage.dart';
import 'category.dart';
//import 'https://flutlab.io/root/app/lib/MyHomePage.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My Drawer',
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.pink),
home: MyHomePage(),
routes: <String, WidgetBuilder>{
"/a": (BuildContext context) => category()
},
);
}
}
MyHomePage.dart
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My Drawer App'),
),
drawer: Drawer(
child: ListView(
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text('Dipanshu'),
accountEmail: Text('dipanshukumar12345678@gmail.com'),
currentAccountPicture: CircleAvatar(
child: Text('Kumar'),
backgroundColor: Colors.orange,
),
),
ListTile(
title: Text('Home'),
trailing: Icon(Icons.home),
),
ListTile(
title: Text('Category'),
trailing: Icon(Icons.card_travel),
onTap: () => Navigator.of(context).pushNamed("/a"),
),
ListTile(
title: Text('Profile'),
trailing: Icon(Icons.more),
),
Divider(),
ListTile(
title: Text('Mascot'),
trailing: Icon(Icons.local_gas_station),
),
Divider(),
ListTile(
title: Text('Close'),
trailing: Icon(Icons.close),
onTap: () => Navigator.of(context).pop(),
),
],
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Home Page"),
],
),
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.green,
child: Icon(Icons.cloud_circle),
onPressed: () {},
),
);
}
}
Category.dart
import 'package:flutter/material.dart';
class category extends StatelessWidget {
const category({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Category Page'),
),
body: Center(
child: Text('A Simple Category Page'),
),
);
}
}
Output :
Comments
Post a Comment