……

Flutter 碎知识(三) 弹窗

Posted on 2022-08-13 17:03  WALL*E  阅读(409)  评论(0编辑  收藏  举报

带有输入框的弹窗

//弹窗
  Future<void> _chooseNetWork(context) async {
    late String  _password;
    showCupertinoDialog(
        context: context,
        builder: (context) {
          return CupertinoAlertDialog(
            title: Text('退出当前模式'),//不想有输入框直接去掉即可
            content: Card(
              elevation: 0.0,
              child: Column(
                children: <Widget>[
                  TextField(
                    onChanged: (v) => _password = v,
                    decoration: InputDecoration(
                      hintText: "请输入",
                    ),
                  ),
                ],
              ),
            ),
            actions: <Widget>[
              CupertinoDialogAction(
                onPressed: () {
                  Navigator.pop(context);//关闭当前弹窗
                },
                child: Text('取消'),
              ),
              CupertinoDialogAction(
                onPressed: () {
                  Navigator.of(context).pop();//先关闭再跳转页面
                  _back(_password);
                },
                child: Text('确定'),
              ),
            ],
          );
        });
  }

提示框

Fluttertoast.showToast(
   msg: result.message,
   gravity: ToastGravity.CENTER,
   fontSize: 20
);

个人使用,仅供参考。