微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 SlideDrawer() 的情况下,在 null 上调用 toggle() 或 open() 方法

如何解决在 SlideDrawer() 的情况下,在 null 上调用 toggle() 或 open() 方法

// 这是我的代码

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Irr Alert"),backgroundColor: Colors.orange,leading: IconButton(
          icon: Icon(Icons.menu),onpressed: () => SlideDrawer.of(context).toggle(),),body: Container(
        height: MediaQuery.of(context).size.height,child: Center(
          child: SingleChildScrollView(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,mainAxisAlignment: MainAxisAlignment.center,children: [
                GestureDetector(
                  onTap: () {
                    Navigator.push(context,MaterialPageRoute(builder: (context) => AddDevice()));
                  },child: Column(
                    children: [
                      Container(
                        child: Image.network(
                          addDevice,height: 150,width: 150,SizedBox(
                        height: 10,Text(
                        "Add Device",style: TextStyle(fontSize: 25),],SizedBox(
                  height: 20,GestureDetector(
                  onTap: () {
                    Navigator.push(context,MaterialPageRoute(builder: (context) => ShowDevices()));
                  },child: Column(
                    children: [
                      Image.network(
                        showDevice,Text(
                        "Show Device",MaterialPageRoute(builder: (context) => CropDetails()));
                  },child: ClipRRect(
                    borderRadius: BorderRadius.circular(70),child: Image.network(
                      cropSeeds,fit: BoxFit.cover,SizedBox(
                  height: 10,Text(
                  "Crop Details",);

解决方法

您没有将键分配给幻灯片抽屉,

` final GlobalKey scaffoldKey = new GlobalKey();

脚手架( 钥匙:脚手架钥匙, 抽屉:AppDrawer(scaffoldKey), body:Container());

`

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。