Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.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
Android 如何通过单击颤振中屏幕的其他区域来管理警报对话框?_Android_Flutter_Dart_Flutter Alertdialog - Fatal编程技术网

Android 如何通过单击颤振中屏幕的其他区域来管理警报对话框?

Android 如何通过单击颤振中屏幕的其他区域来管理警报对话框?,android,flutter,dart,flutter-alertdialog,Android,Flutter,Dart,Flutter Alertdialog,我的应用程序中有一个活动。我正在使用警报对话框。当我到达该活动时,警报对话框打开,当我单击屏幕的其他区域时,它消失了,但问题是,当我想单击任何文本字段的内部时,它会一次又一次地重新出现。我希望这样,一旦它消失,新的会再次出现,直到我转到其他活动并再次返回此活动。我是个新手,几天来我一直面临这个问题,我搜索了很多次这个问题,但都没有找到解决方法,任何能帮助我的人,提前谢谢。 代码 import 'package:flutter/cupertino.dart'; import 'packag

我的应用程序中有一个活动。我正在使用警报对话框。当我到达该活动时,警报对话框打开,当我单击屏幕的其他区域时,它消失了,但问题是,当我想单击任何文本字段的内部时,它会一次又一次地重新出现。我希望这样,一旦它消失,新的会再次出现,直到我转到其他活动并再次返回此活动。我是个新手,几天来我一直面临这个问题,我搜索了很多次这个问题,但都没有找到解决方法,任何能帮助我的人,提前谢谢。 代码

    import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'bottomnavigationbar.dart';

class Contact extends StatefulWidget {
  @override
  _ContactState createState() => _ContactState();
}

class _ContactState extends State<Contact> {
  @override
  Widget build(BuildContext context) {
    AlertDialog dialog = new AlertDialog(
      content: Container(
        width: 260.0,
        height: 187.0,
        decoration: new BoxDecoration(
          shape: BoxShape.rectangle,
          //  color: const Color(0xFFFFFF),
          borderRadius: new BorderRadius.all(new Radius.circular(50.0)),
        ),
        child: Column(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.all(1),
            ),
            Container(
              child: GestureDetector(
                onTap: () {
//                Route route =
//                    MaterialPageRoute(builder: (context) => Payment1());
//                Navigator.pushReplacement(context, route);
                  //  Navigator.pushNamed(context, "myRoute");
                },
                child: new Text(
                  "For Bikes-979578-6541",
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    color: Colors.red,
                    fontSize: 18,
                    //  fontWeight: FontWeight.w700,
                  ),
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(1),
            ),
            Divider(
              thickness: 1.5,
            ),
            Padding(
              padding: EdgeInsets.all(1),
            ),
            Container(
              child: GestureDetector(
                onTap: () {
//                Route route =
//                    MaterialPageRoute(builder: (context) => Payment1());
//                Navigator.pushReplacement(context, route);
                  //  Navigator.pushNamed(context, "myRoute");
                },
                child: new Text(
                  "For Boats-979-541-3607",
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    color: Colors.red,
                    fontSize: 18,
                    //fontWeight: FontWeight.w700,
                  ),
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(1),
            ),
            Divider(
              thickness: 1.5,
            ),
            Padding(
              padding: EdgeInsets.all(1),
            ),
            Container(
              child: GestureDetector(
                onTap: () {
//                Route route =
//                    MaterialPageRoute(builder: (context) => Payment1());
//                Navigator.pushReplacement(context, route);
                  //  Navigator.pushNamed(context, "myRoute");
                },
                child: new Text(
                  "redtiderentals@yahoo.com",
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    color: Colors.red,
                    fontSize: 18,
                    // fontWeight: FontWeight.w700,
                  ),
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(1),
            ),
            Divider(
              thickness: 1.5,
            ),
            Padding(
              padding: EdgeInsets.all(1),
            ),
            Container(
              child: GestureDetector(
                onTap: () {
//                Route route =
//                    MaterialPageRoute(builder: (context) => Payment1());
//                Navigator.pushReplacement(context, route);
                  //  Navigator.pushNamed(context, "myRoute");
                },
                child: new Text(
                  "Follow Us on Facebook!",
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    color: Colors.red,
                    fontSize: 18,
                    //  fontWeight: FontWeight.w700,
                  ),
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(1),
            ),
            Divider(
              thickness: 1.5,
            ),
            Padding(
              padding: EdgeInsets.all(1),
            ),
            Container(
              child: GestureDetector(
                onTap: () {
                  //    Navigator.pop(dialog);
//                Route route =
//                    MaterialPageRoute(builder: (context) => Payment1());
//                Navigator.pushReplacement(context, route);
                  //  Navigator.pushNamed(context, "myRoute");
                  //   Navigator.of(context).pop(false),
                },
                child: new Text(
                  "Done",
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    color: Colors.red,
                    fontSize: 18,
                    //fontWeight: FontWeight.w700,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
    Future.delayed(
      Duration.zero,
      () => showDialog(
          context: context, builder: (BuildContext context) => dialog),
    );

    TextStyle style = TextStyle(
        fontFamily: 'Montserrat', color: Colors.white, fontSize: 16.0);

    return Scaffold(
      appBar: AppBar(
        title: Text("Contact"),
        centerTitle: true,
        actions: <Widget>[
          new IconButton(
            icon: new Icon(
              Icons.more_horiz,
              size: 35,
              color: Colors.white,
            ),
            //  tooltip: 'Closes application',
            //   onPressed: () => exit(0),
          ),
        ],
      ),
      body: SingleChildScrollView(
        child: Container(
          padding: EdgeInsets.all(1),
          color: Colors.black,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Container(
                width: MediaQuery.of(context).size.width,
                height: MediaQuery.of(context).size.width / 1.6,
                //  constraints: BoxConstraints.expand(),
                decoration: BoxDecoration(
                  image: DecorationImage(
                      image: AssetImage("images/contactpage.png"),
                      fit: BoxFit.cover),
                ),
              ),
              Padding(
                padding: EdgeInsets.all(8),
              ),
              Text(
                "Contact Info",
                style: TextStyle(
                  color: Colors.red,
                  fontSize: 20,
                  fontWeight: FontWeight.w400,
                ),
              ),
              Padding(
                padding: EdgeInsets.all(8),
              ),
              Divider(
                color: Colors.white,
                indent: 40,
                endIndent: 40,
              ),
              Padding(
                padding: EdgeInsets.all(8),
              ),
              Container(
                  padding: EdgeInsets.all(16),
                  child: Column(
                    //mainAxisAlignment: MainAxisAlignment.center,

                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        "We are a locally owned. family run business providing equipment rentals in Matagorda Country. We are dedicated to making your experience with us go as smoothly as possible. Fill out the form below or call us if you have any questions or concerns.",
                        style: TextStyle(
                          color: Colors.white70,
                          fontSize: 15,
                          fontWeight: FontWeight.w400,
                        ),
                      ),
                      Text(
                        "Mobile No:",
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 20,
                            fontWeight: FontWeight.w400),
                      ),
                      TextField(
                        style: style,
                        maxLength: 30,
                        cursorColor: Colors.red,
                        textAlign: TextAlign.left,
                        keyboardType: TextInputType.number,
                        decoration: InputDecoration(
                          hintText: 'Enter your mobile number',
                          hintStyle:
                              TextStyle(fontSize: 16, color: Colors.white),
                          border: OutlineInputBorder(
                            borderRadius: BorderRadius.circular(8),
                            borderSide: BorderSide(
                              width: 0,
                              style: BorderStyle.none,
                            ),
                          ),
                          filled: true,
                          fillColor: Color(0xFF1E1E1E),
                          contentPadding: EdgeInsets.all(16),
                        ),
                      ),
                      Text(
                        "Email:",
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 20,
                            fontWeight: FontWeight.w400),
                      ),
                      TextField(
                        style: style,
                        maxLength: 16,
                        cursorColor: Colors.red,
                        textAlign: TextAlign.left,
                        keyboardType: TextInputType.emailAddress,
                        decoration: InputDecoration(
                          hintText: 'Enter your email',
                          hintStyle:
                              TextStyle(fontSize: 16, color: Colors.white),
                          border: OutlineInputBorder(
                            borderRadius: BorderRadius.circular(8),
                            borderSide: BorderSide(
                              width: 0,
                              style: BorderStyle.none,
                            ),
                          ),
                          filled: true,
                          fillColor: Color(0xFF1E1E1E),
                          contentPadding: EdgeInsets.all(16),
                        ),
                      ),
                      Text(
                        "Description:",
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 20,
                            fontWeight: FontWeight.w400),
                      ),
                      TextField(
                        keyboardType: TextInputType.text,
                        maxLines: 8,
                        maxLength: 1000,
                        style: style,
                        cursorColor: Colors.red,
                        textAlign: TextAlign.left,
                        decoration: InputDecoration(
                          hintText: 'Enter Description Here',
                          hintStyle:
                              TextStyle(fontSize: 16, color: Colors.white),
                          border: OutlineInputBorder(
                            borderRadius: BorderRadius.circular(8),
                            borderSide: BorderSide(
                              width: 0,
                              style: BorderStyle.none,
                            ),
                          ),
                          filled: true,
                          fillColor: Color(0xFF1E1E1E),
                          contentPadding: EdgeInsets.all(16),
                        ),
                      ),
                      Material(
                        elevation: 5.0,
                        borderRadius: BorderRadius.circular(30.0),
                        color: Colors.red,
                        child: MaterialButton(
                          minWidth: MediaQuery.of(context).size.width,
                          padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
                          onPressed: () {
//                        Route route =
//                        MaterialPageRoute(builder: (context) => Payment2());
//                        Navigator.pushReplacement(context, route);
                          },
                          child: Text("Submit",
                              textAlign: TextAlign.center,
                              style: style.copyWith(
                                  color: Colors.white,
                                  fontWeight: FontWeight.w800)),
                        ),
                      ),
                    ],
                  ))
            ],
          ),
        ),
      ),
      bottomNavigationBar: BottomNavigation(),
    );
  }
}
import'包装:flift/cupertino.dart';
进口“包装:颤振/材料.省道”;
导入'bottomnavigationbar.dart';
类联系人扩展StatefulWidget{
@凌驾
_ContactState createState();
}
类_ContactState扩展状态{
@凌驾
小部件构建(构建上下文){
AlertDialog=新建AlertDialog(
内容:容器(
宽度:260.0,
身高:187.0,
装饰:新盒子装饰(
形状:BoxShape.rectangle,
//颜色:常量颜色(0xFFFFFF),
borderRadius:新的borderRadius.all(新半径.圆形(50.0)),
),
子:列(
儿童:[
填充物(
填充:边缘设置。全部(1),
),
容器(
儿童:手势检测器(
onTap:(){
//路线=
//MaterialPageRoute(生成器:(上下文)=>Payment1();
//pushReplacement(上下文、路线);
//Navigator.pushNamed(上下文,“myRoute”);
},
儿童:新文本(
“适用于自行车-979578-6541”,
textAlign:textAlign.center,
样式:TextStyle(
颜色:颜色,红色,
尺码:18,
//fontWeight:fontWeight.w700,
),
),
),
),
填充物(
填充:边缘设置。全部(1),
),
分隔器(
厚度:1.5,
),
填充物(
填充:边缘设置。全部(1),
),
容器(
儿童:手势检测器(
onTap:(){
//路线=
//MaterialPageRoute(生成器:(上下文)=>Payment1();
//pushReplacement(上下文、路线);
//Navigator.pushNamed(上下文,“myRoute”);
},
儿童:新文本(
“适用于船只-979-541-3607”,
textAlign:textAlign.center,
样式:TextStyle(
颜色:颜色,红色,
尺码:18,
//fontWeight:fontWeight.w700,
),
),
),
),
填充物(
填充:边缘设置。全部(1),
),
分隔器(
厚度:1.5,
),
填充物(
填充:边缘设置。全部(1),
),
容器(
儿童:手势检测器(
onTap:(){
//路线=
//MaterialPageRoute(生成器:(上下文)=>Payment1();
//pushReplacement(上下文、路线);
//Navigator.pushNamed(上下文,“myRoute”);
},
儿童:新文本(
"redtiderentals@yahoo.com",
textAlign:textAlign.center,
样式:TextStyle(
颜色:颜色,红色,
尺码:18,
//fontWeight:fontWeight.w700,
),
),
),
),
填充物(
填充:边缘设置。全部(1),
),
分隔器(
厚度:1.5,
),
填充物(
填充:边缘设置。全部(1),
),
容器(
儿童:手势检测器(
onTap:(){
//路线=
//MaterialPageRoute(生成器:(上下文)=>Payment1();
//pushReplacement(上下文、路线);
//Navigator.pushNamed(上下文,“myRoute”);
},
儿童:新文本(
“在Facebook上关注我们!”,
textAlign:textAlign.center,
样式:TextStyle(
颜色:颜色,红色,
尺码:18,
//fontWeight:fontWeight.w700,
),
),
),
),
填充物(
填充:边缘设置。全部(1),
),
分隔器(
厚度:1.5,
),
填充物(
填充:边缘设置。全部(1),
),
容器(
儿童:手势检测器(
onTap:(){
//Navigator.pop(对话框);
//路线=
//MaterialPageRoute(生成器:(上下文)=>Payment1();
//pushReplacement(上下文、路线);
//Navigator.pushNamed(上下文,“myRoute”);
//Navigator.of(context.pop)(false),
},
儿童:新文本(
“完成”,
textAlign:textAlign.center,
样式:TextStyle(
颜色:颜色,红色,
尺码:18,
//fontWeight:fontWeight.w700,
),
),
),
),
],
),
),
);
推迟(
持续时间0.0,
()=>显示对话框(
续
createAlertDialog(BuildContext){ 
return AlertDialog( //Your work ) 
@override   Widget build(BuildContext context) { 
//Whenver you need alertdialog call createAlertDialog()  }```
class _ContactState extends State<Contact> {
        
     @override
      void initState() {
        super.initState();
        Future.delayed(
            Duration.zero,
            () => showDialog(
                  context: context,
                  barrierDismissible: true, 
                  builder: (_) => AlertDialog(
                   // content

               ),
            )   
         );
       }
        
     @override
     Widget build(BuildContext context) {
       //your original code without the AlertDialog widget
     }
}