Looking up a deactivated widget's ancestor is unsafe

前端 未结 5 2070
鱼传尺愫
鱼传尺愫 2020-12-29 03:46

I am new in Flutter and I am trying receive data with a Dialog. When a click in textField the error of image2 appear...

5条回答
  •  自闭症患者
    2020-12-29 03:53

    Try this:

        Future myDialog(BuildContext context) {
        return showDialog(
          context: context,
          builder: (BuildContext context) {
            return AlertDialog(
              content: Container(
                margin: EdgeInsets.all(8.0),
                child: Form(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      TextFormField(
                        decoration: InputDecoration(
                            labelText: "Insira o número de telefone",
                            border: OutlineInputBorder(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(2.0)))),
                      ),
                    ],
                  ),
                ),
              ),
              actions: [
                FlatButton(
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                    child: Text("Cancelar")),
                FlatButton(
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                    child: Text("Aceitar"))
              ],
            );
          },
        );
      }
    

提交回复
热议问题