其他分享
首页 > 其他分享> > CupertinoAlertDialog

CupertinoAlertDialog

作者:互联网

由于CupertinoDialog已经被标记为过时的Widget,这里就只介绍CupertinoAlertDialog的用法。

showDialog( //通过showDialog方法展示alert弹框
  context: context,
  builder: (context) {
    return CupertinoAlertDialog(
      title: Text('提示'), //弹框标题
      content: Text('是否想放弃学习Flutter'), //弹框内容
      actions: <Widget>[ //操作控件
        CupertinoDialogAction(
          onPressed: () { //控件点击监听
            print("我不会放弃的");
            Navigator.pop(context);
          },
          textStyle: TextStyle(fontSize: 18, color: Colors.blueAccent), //按钮上的文本风格
          child: Text('取消'), //控件显示内容
        ),
        CupertinoDialogAction(
          onPressed: () {
            print("我投降");
            Navigator.pop(context);
          },
          textStyle: TextStyle(fontSize: 18, color: Colors.grey),
          child: Text('确定'),
        ),
      ],
    );
  },
);

 

标签:TextStyle,控件,Text,弹框,context,CupertinoAlertDialog
来源: https://www.cnblogs.com/timba1322/p/12487030.html