我的应用程序加载到起始页面上,加载页面后,我需要自动显示抽屉菜单,如何打开此菜单?在中void main()
,具有:
new MaterialApp(
initialRoute: '/page',
builder: (context, widget) {
return new Padding(
child: widget,
padding: new EdgeInsets.only(bottom: 10.0),
);
void main() => runApp(MaterialApp(home: AppPage()));
class AppPage extends StatefulWidget {
@override
_AppPageState createState() => _AppPageState();
}
class _AppPageState extends State<AppPage> {
final GlobalKey<ScaffoldState> _key = GlobalKey();
@override
void initState() {
super.initState();
Timer.run(() => _key.currentState.openDrawer());
}
@override
Widget build(BuildContext context) {
return Scaffold(
key: _key,
appBar: AppBar(),
drawer: Drawer(),
);
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句