发布于 5年前

flutter 弹窗 alert

// 展示弹窗使用 showDialog 方法
Future<T> showDialog<T>({
  @required BuildContext context,
  bool barrierDismissible = true,
  @Deprecated(
    'Instead of using the "child" argument, return the child from a closure '
    'provided to the "builder" argument. This will ensure that the BuildContext '
    'is appropriate for widgets built in the dialog.'
  ) Widget child,
  WidgetBuilder builder,
})

// flutter 提供了一个简单的 AlertDialog
showDialog(
  // 是否允许用户按返回按钮关闭弹窗
  barrierDismissible: false,
  context: context,
  builder: ( ctx ) {
    return AlertDialog(
      title: Text("提示"),
      content: Text("我是一个弹窗")
    )
  }
)

// 关闭弹窗可使用
Navigator.of(context).pop();
©2020 edoou.com   京ICP备16001874号-3