flutter_advanced_drawer 1.0.0 flutter_advanced_drawer: ^1.0.0 copied to clipboard
An advanced drawer widget, that can be fully customized with size, text, color, radius of corners.
import 'package:flutter/material.dart';
import 'package:flutter_advanced_drawer/flutter_advanced_drawer.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomeScreen(),
);
}
}
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final _advancedDrawerController = AdvancedDrawerController();
@override
Widget build(BuildContext context) {
AdvancedDrawer(
backdropColor: Colors.blueGrey,
controller: _advancedDrawerController,
child: SizedBox(),
drawer: SizedBox(),
);
return AdvancedDrawer(
backdropColor: Colors.blueGrey,
controller: _advancedDrawerController,
child: Scaffold(
appBar: AppBar(
title: const Text('Advanced Drawer Example'),
leading: IconButton(
onPressed: _handleMenuButtonPressed,
icon: ValueListenableBuilder<AdvancedDrawerValue>(
valueListenable: _advancedDrawerController,
builder: (context, value, child) {
return Icon(
value.visible ? Icons.clear : Icons.menu,
);
},
),
),
),
body: Container(),
),
drawer: SafeArea(
child: Container(
child: ListTileTheme(
textColor: Colors.white,
iconColor: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: 128.0,
height: 128.0,
margin: const EdgeInsets.only(
top: 24.0,
bottom: 64.0,
),
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: Colors.black26,
shape: BoxShape.circle,
),
child: Image.asset(
'assets/images/flutter_logo.png',
),
),
ListTile(
onTap: () {},
leading: Icon(Icons.home),
title: Text('Home'),
),
ListTile(
onTap: () {},
leading: Icon(Icons.account_circle_rounded),
title: Text('Profile'),
),
ListTile(
onTap: () {},
leading: Icon(Icons.favorite),
title: Text('Favourites'),
),
ListTile(
onTap: () {},
leading: Icon(Icons.settings),
title: Text('Settings'),
),
Spacer(),
DefaultTextStyle(
style: TextStyle(
fontSize: 12,
color: Colors.white54,
),
child: Container(
margin: const EdgeInsets.symmetric(
vertical: 16.0,
),
child: Text('Terms of Service | Privacy Policy'),
),
),
],
),
),
),
),
);
}
void _handleMenuButtonPressed() {
// NOTICE: Manage Advanced Drawer state through the Controller.
// _advancedDrawerController.value = AdvancedDrawerValue.visible();
_advancedDrawerController.showDrawer();
}
}