Created
May 24, 2018 15:01
-
-
Save kleinlennart/3e07133274ae8ac2d1187855ce2c7e51 to your computer and use it in GitHub Desktop.
Flutter Custom Drawer Icon (use keys)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _HomePageState extends State<HomePage> { | |
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
key: _scaffoldKey, | |
appBar: new AppBar( | |
title: new Text("App"), | |
leading: new IconButton( | |
icon: new Icon(Icons.apps), | |
onPressed: () => _scaffoldKey.currentState.openDrawer())), | |
drawer: new Drawer()); | |
} | |
} |
This is smart
I receive an error
openDrawer() call on null
I receive an error
openDrawer() call on null
Have you initialised the Drawer correctly and is it assigned to the drawer attribute of the Scaffold?
you can use 'Scaffold.of(context).openDrawer()' instead
But the dragging will stop working
you can use 'Scaffold.of(context).openDrawer()' instead
it works perfectly.
But the dragging will stop working
It's working with me
smooooth hax
you can use 'Scaffold.of(context).openDrawer()' instead
That worked for me. :) thanks
worked very well, thanks !
it's working good..thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!!!