sweetalertv2

sweetalertv2 for flutter。

展示

preview--1--2

入门

添加依赖

sweetalertv2: any

用法

基本用法

1--3-

SweetAlertV2.show(context, title: "Just show a message");

带副标题

2--3-

SweetAlertV2.show(context,
	title: "Just show a message",
	subtitle: "Sweet alert is pretty");

带有成功状态

3--2-

SweetAlertV2.show(context,
	title: "Just show a message",
	subtitle: "Sweet alert is pretty",
	style: SweetAlertV2Style.success);

带有确认状态

4--1-

SweetAlertV2.show(context,
	title: "Just show a message",
	subtitle: "Sweet alert is pretty",
	style: SweetAlertV2Style.confirm,
	showCancelButton: true, onPress: (bool isConfirm) {
		if (isConfirm) {
			SweetAlertV2.show(context,style: SweetAlertV2Style.success,title: "Success");
			// return false to keep dialog
			return false;
        }
	});

做一些工作

SweetAlertV2.show(context,
	subtitle: "Do you want to delete this message",
	style: SweetAlertV2Style.confirm,
	showCancelButton: true, onPress: (bool isConfirm) {
		if(isConfirm){
			SweetAlertV2.show(context,subtitle: "Deleting...", style: SweetAlertV2Style.loading);
			new Future.delayed(new Duration(seconds: 2),(){
				SweetAlertV2.show(context,subtitle: "Success!", style: SweetAlertV2Style.success);
			});
		}else{
			SweetAlertV2.show(context,subtitle: "Canceled!", style: SweetAlertV2Style.error);
		}

		// return false to keep dialog
		return false;
	});

特别鸣谢

  • best-flutter (初始项目)

GitHub

https://github.com/brunominervino/sweetalertv2