Drawer is one of the main component of an application. It is like a package which can be used for following purposes at a single place-
1. Navigate users to different pages.
2. Login
3. LogOut
4. Settings
5. Contact Page
Drawer makes it easy to work with any application. It's important for making the User experience more easier.
Prerequisties -
Create assets folder and add user.png image in it. Don't forget to add assets folder in pubspec.yaml otherwise it will cause errors.
Let's see code in flutter for Drawer-
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
appBar: AppBar(
title: Text("Drawer demo"),
),
drawer: Drawer(
child: Column(
children: <Widget>[
Stack(
children: [
Container(
margin: EdgeInsets.only(top: 60,right: 150),
color: Colors.white,
child: Image.asset("assets/user.png"),
width: 100,
height: 100,
),
Positioned(
right: 0,
top: 60,
child: Text("Cool Trends",style: TextStyle(color: Colors.black,fontSize: 20,fontWeight: FontWeight.w600),)
,),
Positioned(
top: 80,
right: 0,
child: Text("cooltrends@gmail.com",style: TextStyle(color: Colors.black,fontSize: 15,fontWeight: FontWeight.w500),),
)
],
),
SizedBox(height: 60,),
ListTile(
leading: Icon(Icons.account_circle),
title: Text("Account"),
),
ListTile(
leading: Icon(Icons.settings),
title: Text("Settings"),
),
ListTile(
leading: Icon(Icons.lightbulb_outline),
title: Text("InSight"),
),
ListTile(
leading: Icon(Icons.feedback),
title: Text("FeedBack"),
)
],
),
),
),
);
}
}
This is drawer we created using this code -
Comments
Post a Comment