Support : https://paypal.me/ripplescode
In this video I have discussed about Drawer image nd pubspec.yaml in flutter.
import 'package:flutter/material.dart';
void main() =greater runApp(MyWidget());
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "Ripples Code",
theme: ThemeData(primarySwatch: Colors.deepPurple),
home: MyScaffold());
}
}
class MyScaffold extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: Drawer(
child: getDrawerItem(context),
),
appBar: getAppBar(),
body: getBody(),
);
}
Widget getDrawerItem(BuildContext context) {
return ListView(
children: lessthanWidgetgreaterthan[
UserAccountsDrawerHeader(
accountEmail: Text("[email protected]"),
accountName: Text("Amar"),
currentAccountPicture: CircleAvatar(
child: Text("AK"),
backgroundColor: Colors.white,
backgroundImage: AssetImage('images/amar.jpg'),
),
otherAccountsPictures: lessthanWidgetgreaterthan
CircleAvatar(
child: Text("AK"),
backgroundColor: Colors.white,
backgroundImage: AssetImage('images/amar.jpg'),
),
],
onDetailsPressed: (){debugPrint("Ripples Code");},
),
ListTile(
title: Text("Item-1"),
trailing: Icon(Icons.add),
),
ListTile(
title: Text("Item-2"),
trailing: Icon(Icons.add),
),
Divider(),
ListTile(
title: Text("Close"),
trailing: Icon(Icons.add),
onTap: () {
Navigator.of(context).pop();
},
),
],
);
}
Widget getAppBar() {
return AppBar(
title: Text(
"App Bar",
),
actions: lessthanWidgetgreaterthan[
IconButton(
icon: Icon(Icons.shopping_cart),
onPressed: (null),
),
IconButton(
icon: Icon(Icons.monetization_on),
onPressed: () {},
),
],
);
}
Widget getBody()
{
return Material
(
color: Colors.lightBlue,
child: Center(
child: Text("Ripples Code",
textDirection: TextDirection.ltr,
style: TextStyle(color: Colors.white, fontSize: 40.0))),
);
}
}