📌  相关文章
📜  以编程方式打开抽屉 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:46.887000             🧑  作者: Mango

代码示例1
final GlobalKey _key = GlobalKey(); // Create a key

@override
Widget build(BuildContext context) {
  return Scaffold(
    key: _key, // Assign the key to Scaffold.
    drawer: Drawer(),
    floatingActionButton: FloatingActionButton(
      onPressed: () => _key.currentState!.openDrawer(), // <-- Opens drawer
    ),
  );
}