Dialog
弹出框
YmUiUtil.showLoading(context); Future.delayed(Duration(seconds: 3), () { YmUiUtil.hideLoading(context); });
YmUiUtil.showAlertDialog(context, "确认提示", "您确定要打开弹窗吗?", "确定", "取消",onOkPressed: (){ print("Ok Pressed"); });
///显示弹出框 static showAlertDialog(BuildContext context,String title,String message,String okText,String cancelText,{onOkPressed,onCancelPressed,okCloseDialog = true}){ showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( title: Text(title), content: SingleChildScrollView( child: ListBody( children:[ Text(message), ], ), ), actions:[ TextButton( child: Text(cancelText), onPressed: () { if(null != onCancelPressed){ onCancelPressed(); } Navigator.of(context).pop(); }, ), TextButton( child: Text(okText), onPressed: () { if(null != onOkPressed){ onOkPressed(); } if(null != okCloseDialog && okCloseDialog){ Navigator.of(context).pop(); } }, ), ], ); }, ).then((val) { print(val); }); }
自定义弹出框
static showBottomDialog(BuildContext context,Widget child){ showDialog( context: context, barrierDismissible: true, builder: (BuildContext context) { return YmDialogBox(child:child); }, ).then((val) { print(val); }); }
本站内容来源于作者发布和网络转载,如有版权相关问题请及时与我们取得联系,我们将立即删除。