Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在颤振中禁用模态底部板材上的“后退”按钮?_Flutter_Bottom Sheet_Flutter Showmodalbottomsheet_Bottom - Fatal编程技术网

Flutter 如何在颤振中禁用模态底部板材上的“后退”按钮?

Flutter 如何在颤振中禁用模态底部板材上的“后退”按钮?,flutter,bottom-sheet,flutter-showmodalbottomsheet,bottom,Flutter,Bottom Sheet,Flutter Showmodalbottomsheet,Bottom,若屏幕上出现底部纸张,我希望禁用“后退”按钮。 当我使用willpop作用域时,它向我显示了一个错误,即未来(动态不能分配给小部件)。 我怎样才能解决这个问题 1. 若屏幕上出现底部纸张,我希望禁用“后退”按钮。 当我使用willpop作用域时,它向我显示了一个错误,即未来(动态不能分配给小部件)。 我怎样才能解决这个问题 1. 若屏幕上出现底部纸张,我希望禁用“后退”按钮。 当我使用willpop作用域时,它向我显示了一个错误,即未来(动态不能分配给小部件)。 我怎样才能解决这个问题 if

若屏幕上出现底部纸张,我希望禁用“后退”按钮。 当我使用willpop作用域时,它向我显示了一个错误,即未来(动态不能分配给小部件)。 我怎样才能解决这个问题 1. 若屏幕上出现底部纸张,我希望禁用“后退”按钮。 当我使用willpop作用域时,它向我显示了一个错误,即未来(动态不能分配给小部件)。 我怎样才能解决这个问题 1. 若屏幕上出现底部纸张,我希望禁用“后退”按钮。 当我使用willpop作用域时,它向我显示了一个错误,即未来(动态不能分配给小部件)。 我怎样才能解决这个问题

 if (_registerModel.status == "success") {
                            saveUserIDToSharedPreference(
                                "userID", _registerModel.id);
                            String displayToast =
                                "Registration successful \n OTP is ${_registerModel.otp}";
                            Fluttertoast.showToast(
                              msg: displayToast,
                              toastLength: Toast.LENGTH_LONG,
                              gravity: ToastGravity.BOTTOM,
                              timeInSecForIosWeb: 1,
                            );
                            buildShowEnterOTPModalBottomSheet(
                                context,
                                size,
                                email,
                                password,
                                _registerModel.id,
                                _registerModel.otp);
                          }
Future buildshowtentropodbottomsheet(
BuildContext上下文、大小、字符串电子邮件、int-id){
VerifyOtpModel _VerifyOtpModel;
最终TextEditingController otpController=TextEditingController();
返回showModalBottomSheet(
isDismissible:错误,
enableDrag:false,
是的,
形状:圆形矩形边框(
边界半径:边界半径。垂直(顶部:半径。圆形(20.0)),
),
上下文:上下文,
生成器:(上下文){
返回动画填充(
持续时间:持续时间(毫秒:150),
曲线:Curves.easeOut,
填充:仅限边缘设置(
底部:MediaQuery.of(context.viewInsets.bottom),
子:列(
mainAxisSize:mainAxisSize.min,
儿童:[
填充物(
填充:LTRB(0,24.0,0,18.0)中的常量边集,
子:容器(
宽度:80.0,
身高:80.0,
子:Image.asset(
“资产/图像/发送电子邮件.png”,
适合度:BoxFit.fit高度,
身高:80,
宽度:80,
),
),
),
正文(
“验证您的电子邮件ID”,
样式:TextStyle(
颜色:颜色(0xFF707070),
fontFamily:“简单四舍五入”,
字体大小:16.0),
),
填充物(
填充:LTRB(32.0,8.0,32.0,16.0)中的常量边集,
子:文本(
“请输入4位代码发送到\n”+电子邮件,
样式:TextStyle(
颜色:常量颜色(0xFF707070),
字体大小:14.0,
fontWeight:fontWeight.w500,
fontFamily:“蒙特塞拉特中号”,
),
textAlign:textAlign.center,
),
),
填充物(
填充:LTRB(32.0,0,32.0,24.0)中的常量边集,
孩子:卡片(
形状:圆形矩形边框(
边界半径:边界半径。圆形(15.0),
),
颜色:颜色,白色,
海拔:20,
孩子:填充(
填充:LTRB(32.0,0,32.0,8.0)中的常量边集,
子项:OTPTextField(
边距:仅限边缘组(底部:10.0),
长度:4,
宽度:MediaQuery.of(context).size.width,
场宽:40,
样式:TextStyle(
尺寸:17,
),
textFieldAlignment:MainAxisAlignment.spaceAround,
fieldStyle:fieldStyle.underline,
未完成:(pin){
打印(“已完成:“+pin”);
otpController.text=pin;
},
一旦更改:(pin){
打印(“更改:+pin”);
otpController.text=pin;
},
),
),
),
),
正文(
“重发代码”,
样式:TextStyle(
颜色:颜色(0xFF1FC27F),
字体大小:14.0,
fontFamily:“蒙特塞拉特中号”,
装饰:textEdition.underline,
),
textAlign:textAlign.center,
),
墨水池(
onTap:()异步{
如果(otpController.text.length尝试此选项

   Future bottomSheet() async {
    return showModalBottomSheet(
      isDismissible: false,
      enableDrag: false,
      isScrollControlled: true,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.vertical(top: Radius.circular(20.0)),
      ),
      context: context,
      builder: (context) {
        return WillPopScope(
          onWillPop: () async => false,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text('text 1'),
              Text('text 2'),
              Text('text 3'),
            ],
          ),
        );
      },
    );
  }
Future bottomSheet()异步{
返回showModalBottomSheet(
isDismissible:错误,
enableDrag:false,
是的,
形状:圆形矩形边框(
边界半径:边界半径。垂直(顶部:半径。圆形(20.0)),
),
上下文:上下文,
生成器:(上下文){
返回式示波器(
onWillPop:()async=>false,
子:列(
mainAxisSize:mainAxisSize.min,
儿童:[
文本(“文本1”),
文本(“文本2”),
文本(“文本3”),
],
),
);
},
);
}
这很有效

    showModalBottomSheet( 
     context: context,
     builder: (context) {
      return WillPopScope(
        onWillPop: () async => false,
        child: child,
      );
     },
    )
问题:无法将未来(动态)分配给小部件

 Scaffold(
   body: showModalBottomSheet(
    context,
  ),
解决方案

Scaffold(
  body: ElevatedButton(
    child: Text("Show"),
    onPressed: () => showModalBottomSheet(context),
  ),
)

实际上,我也尝试了相同的方法,但正如您看到的代码一样,底部的工作表代表未来,因此它显示了如下错误。未来(动态)无法分配给小部件。您能告诉我如何调用
buildshowtentertmodalbottomsheet
?我编辑了上述代码。我从我的角度使用了相同的代码,并且它工作得很好。
Scaffold(
  body: ElevatedButton(
    child: Text("Show"),
    onPressed: () => showModalBottomSheet(context),
  ),
)