Issue
Logging into our Flutter app opens to dashboard that has a Scaffold with a Drawer full of menu items.
I'd like to perform some A/B testing with having the Drawer open on page load or at least animating the Drawer being opened immediately on load.
I'm aware of Scaffold.of(context).openDrawer()
but I'm not sure where to place this code so that it will run immediately after the build() method. I'm also not aware of any fields on either Drawer or Scaffold which would load with the Drawer open.
Thanks for your time and help.
Solution
You need to wait after the first frame is loaded.
_onLayoutDone(_) {
//your logic here
}
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback(_onLayoutDone);
super.initState();
}
I wrote a post about this, you can take a look if you want : https://medium.com/@diegoveloper/flutter-widget-size-and-position-b0a9ffed9407
Answered By - diegoveloper
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.