Flutter 颤振:忽略指针不在GestureDetector的子对象上工作
我试图使一个窗体,可以提交一个按钮的细节弹出窗口 当我在我的Diolog中使用“SingleChildScrollView”时,show dialog函数的“barrierDissmissable”属性不再起作用。我想它在某种程度上掩盖了它。我使用“SingleChildScrollView”在键盘出现时保持对话框的形状 因此,我将我的小部件包装在一个手势检测器中,该检测器弹出上下文,这正确地模拟了barrierDissmissable属性为true 现在的问题是,每当我单击对话框的任何部分,除了TextFormFields或Diolog取消的按钮之外。我尝试将其包装在IgnorePointer小部件中,但它无法正常工作Flutter 颤振:忽略指针不在GestureDetector的子对象上工作,flutter,Flutter,我试图使一个窗体,可以提交一个按钮的细节弹出窗口 当我在我的Diolog中使用“SingleChildScrollView”时,show dialog函数的“barrierDissmissable”属性不再起作用。我想它在某种程度上掩盖了它。我使用“SingleChildScrollView”在键盘出现时保持对话框的形状 因此,我将我的小部件包装在一个手势检测器中,该检测器弹出上下文,这正确地模拟了barrierDissmissable属性为true 现在的问题是,每当我单击对话框的任何部分,除
static dynamic showDeleteUserPopup(BuildContext context)async{
return await showDialog(
barrierDismissible: true,
context: context,
builder: (BuildContext context) => DeleteUserDiolog());
}
class\u deleteUserDialogState扩展状态{
final _formKey=GlobalKey();
final_email=TextEditingController();
最终_password=TextEditingController();
@凌驾
小部件构建(构建上下文){
返回新的GestureDetector(onTapDown:(taptdownDetails)=>Navigator.pop(上下文),
子:SingleChildScrollView(
子:对话框(
形状:圆形矩形边框(
borderRadius:borderRadius.all(半径.圆形(32.0)),
儿童:中心(
子:容器(
填充:边缘设置。全部(20),
子:列(
儿童:[
填充(填充:边缘集。全部(10),
子项:Text(“删除您的帐户”,样式:Theme.of(context.textTheme.title,),
填充(填充:边缘集。全部(10),
child:Text(“确认下面的详细信息以删除您的帐户”,style:Theme.of(context.textTheme.subtitle.apply(),textAlign:textAlign.center,),
形式(
键:_formKey,
子:列(
儿童:[
容器(
宽度:300,
填充:边缘设置。全部(10),
子项:TextFormField(
控制员:_电子邮件,
装饰:输入装饰(标签文本:“电子邮件”),
key:key(“电子邮件”),
键盘类型:TextInputType.emailAddress,),
容器(
宽度:300,
填充:边缘设置。全部(10),
子项:TextFormField(
控制器:_密码,
装饰:输入装饰(标签文本:“密码”),
key:key(“密码”),
键盘类型:TextInputType.text,
蒙蔽文字:对,),
]
)
),
铜中毒(
IsDestructionAction:是的,
子项:Text('Delete',样式:Theme.of(context).textTheme.display3.apply(颜色:Colors.red),),
onPressed:()=>Dbf.deleteCurrcuiser(\u email.text,\u password.text)。然后((\u){
popintil(上下文,ModalRoute.withName(Navigator.defaultRouteName));
}).catchError((e){
showAlert('Error',“凭据错误”,'OK',()=>Navigator.pop(context),context);
}),
)
],
)
)
)
)
)
);
}
}
我想能够在黑暗中点击,以消除弹出窗口。当我在“SingleChildScrollView”中包装对话框时,这将停止工作,但我需要这样做,以便在键盘出现时弹出窗口保持其形状
任何帮助都将不胜感激。为什么不尝试调用
showDialog()
调用?是的,这就是我创建弹出窗口的方式,但即使“barrier dismissible”属性设置为true,它也不会关闭。这就是为什么我现在必须用手势检测器来检测它。如上所述,我添加了showDialog代码。为什么不尝试调用showDialog()
呢?是的,这就是我创建弹出窗口的方式,但即使“barrier dismissible”属性设置为true,它也不会关闭。这就是为什么我现在必须用手势检测器来检测它。在我添加showDialog代码时,请参见上文。
class _DeleteUserDiologState extends State<DeleteUserDiolog> {
final _formKey = GlobalKey<FormState>();
final _email = TextEditingController();
final _password = TextEditingController();
@override
Widget build(BuildContext context) {
return new GestureDetector( onTapDown: (tapdownDetails) => Navigator.pop(context),
child: SingleChildScrollView(
child : Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0))),
child: Center(
child: Container(
padding: EdgeInsets.all(20),
child: Column(
children: <Widget>[
Padding(padding: EdgeInsets.all(10),
child: Text( "Delete your account", style: Theme.of(context).textTheme.title,)),
Padding(padding: EdgeInsets.all(10),
child: Text( "Confirm your details below to delete your account", style: Theme.of(context).textTheme.subtitle.apply(), textAlign: TextAlign.center,)),
Form(
key:_formKey,
child: Column(
children: [
Container(
width: 300,
padding: EdgeInsets.all(10),
child:TextFormField(
controller: _email,
decoration: InputDecoration(labelText: 'Email'),
key: Key('email'),
keyboardType: TextInputType.emailAddress,)),
Container(
width: 300,
padding: EdgeInsets.all(10),
child: TextFormField(
controller: _password,
decoration: InputDecoration(labelText: 'Password'),
key: Key('password'),
keyboardType: TextInputType.text,
obscureText: true,)),
]
)
),
CupertinoDialogAction(
isDestructiveAction: true,
child: Text('Delete', style: Theme.of(context).textTheme.display3.apply(color: Colors.red),),
onPressed: () => Dbf.deleteCurrectUser(_email.text, _password.text).then((_){
Navigator.popUntil(context, ModalRoute.withName(Navigator.defaultRouteName));
}).catchError((e){
PopUps.showAlert('Error', "The credentials were wrong.", "OK", () => Navigator.pop(context), context);
}),
)
],
)
)
)
)
)
);
}
}