使用
Key你的
Scaffold,并通过调用显示抽屉
myKey.currentState.openDrawer(),这里是工作的代码:
import "package:flutter/material.dart";class Test extends StatefulWidget { @override _TestState createState() => new _TestState();}class _TestState extends State<Test> { final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); @override Widget build(BuildContext context) { return new Scaffold( key: _scaffoldKey, drawer: new Drawer(), appBar: new AppBar( leading: new IconButton( icon: new Icon(Icons.settings), onPressed: () => _scaffoldKey.currentState.openDrawer(), ), ), ); }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)