PPAlert class
PPAlert
全局弹窗工具类,提供加载中、提示、成功、错误、信息、警告、进度、SnackBar、系统对话框等功能的静态方法。
通常用作 App 通用弹窗提示、加载、进度条等场景。
用法示例
// 显示加载
PPAlert.showLoading(text: "加载中...");
// 隐藏加载
PPAlert.hideLoading();
// 成功提示
PPAlert.showSuccess("操作成功");
// 错误提示
PPAlert.showError("操作失败");
// 警告提示
PPAlert.showWarning("请注意!");
// 自定义SnackBar
PPAlert.showSnackBar(title: "Tip", message: "Something happened!");
// 显示系统确认对话框
PPAlert.showSysConfirm(
title: "确认操作",
message: "是否要继续?",
onConfirm: () { print("用户确认"); },
onCancel: () { print("用户取消"); },
);
Constructors
- PPAlert()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- isAlerted ↔ bool
-
是否已弹出系统对话框
getter/setter pair
- isLoading ↔ bool
-
是否处于加载中状态
getter/setter pair
- snackBarConfig ↔ SnackBarConfig
-
SnackBar 配置项
getter/setter pair
Static Methods
-
dismiss(
) → void - 隐藏加载弹窗
-
hideLoading(
) → void - 隐藏加载弹窗
-
showDoubleTextInput(
{String title = 'Title', String message = '', List< String> ? initialTexts, List<String> ? hintTexts, String cancelLabelText = 'Cancel', String okLabelText = 'OK'}) → Future<List< String> > - 显示双文本输入框弹窗
-
showError(
String message) → void - 显示全局错误提示
-
showInfo(
String message) → void - 显示全局信息提示
-
showLoading(
{String? text, int? timeoutSeconds, Function? onTimeout}) → void - 显示加载中弹窗
-
showProgress(
double progress, {String? status}) → void - 显示带进度的弹窗
-
showSingleTextInput(
{String title = 'Title', String message = '', String initialText = '', String hintText = '', String cancelLabelText = 'Cancel', String okLabelText = 'OK'}) → Future< String> - 显示单个文本输入框弹窗
-
showSnackBar(
{String title = 'Tips', String message = 'Messages', String okLabelText = 'OK', Function? onOK}) → void - 显示自定义SnackBar
-
showSuccess(
String message) → void - 显示全局操作成功提示
-
showSysAlert(
{String title = 'Tips', String message = 'Messages', String okLabelText = 'OK', Function? onOK}) → Future< void> - 显示系统原生确认弹窗(AlertDialog)
-
showSysConfirm(
{String title = 'Confirm', String message = 'Do you want to do it?', String cancelLabelText = 'Cancel', String okLabelText = 'OK', Function? onCancel, required Function onConfirm}) → Future< void> - 显示系统原生确认对话框
-
showToast(
String message) → void - 显示全局Toast提示
-
showWarning(
String message) → void - 显示全局警告提示