Flutter: How to open Drawer programmatically

前端 未结 6 1009
暖寄归人
暖寄归人 2020-12-29 21:11

I want to open Drawer programmatically not by sliding it, how to disable that sliding functionality (touch functionality of Drawer)

6条回答
  •  醉话见心
    2020-12-29 21:44

    To disable the slide to open functionality you can set the property endDrawerEnableOpenDragGesture on Scaffold to false.

    @override
    Widget build(BuildContext context) {
      return Scaffold(
        endDrawerEnableOpenDragGesture: false, // THIS WAY IT WILL NOT OPEN
        drawer: Drawer(),
        appBar: AppBar(
          leading: IconButton(
            icon: Icon(Icons.menu),
            onPressed: () {
              Scaffold.of(context).openDrawer();
            },
          ),
        ),
      );
    }
    

提交回复
热议问题