flutter alert弹出框

1,545 阅读1分钟
import 'package:rflutter_alert/rflutter_alert.dart';

...
Alert(
  context: context,
  style: AlertStyle(
    animationType: AnimationType.fromBottom,  // 动画从什么位置出现
    isCloseButton: false,  // 是否有右上角的关闭按钮,如果有,则必须写closeFunction: (){}
    isOverlayTapDismiss: false,  // 点击其他地方是否关闭弹框
    descStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.red),  // 副标题的样式
    animationDuration: Duration(milliseconds: 400),  // 动画执行时间
    titleStyle: TextStyle(  // title的文字颜色
      color: Colors.blue,
    ),
  ),
  closeFunction: () {},
  type: AlertType.warning, // alert类型,有警告,成功,提示,错误
  title: "是否清除缓存",
  desc: "清除缓存后,加载图片将需要费一定时间哦!",  // 副标题
  buttons: [
    DialogButton(
      child: Text(
        "否",
        style: TextStyle(color: Colors.white, fontSize: 20),
      ),
      onPressed: () => Navigator.pop(context),
      color: Color.fromRGBO(0, 179, 134, 1.0),
      radius: BorderRadius.circular(0.0),
    ),
    DialogButton(
      child: Text(
        "是",
        style: TextStyle(color: Colors.white, fontSize: 20),
      ),
      onPressed: () => Navigator.pop(context),
      color: Color.fromRGBO(0, 179, 134, 1.0),
      radius: BorderRadius.circular(0.0),
    ),
  ],
)

这个插件还有其他样式,可看github github.com/RatelHub/rf…