fastConfirmDialog function

Future<void> fastConfirmDialog(
  1. BuildContext context, {
  2. String title = "温馨提示",
  3. String info = "",
  4. String cancelBtn = "取消",
  5. String sureBtn = "确定",
  6. Color sureColor = Colors.blue,
  7. Callback? onTap,
  8. bool isOnlySureBtn = false,
  9. bool barrierDismissible = true,
  10. double? width,
})

Implementation

Future<void> fastConfirmDialog(BuildContext context, {
  String title = "温馨提示",
  String info = "",
  String cancelBtn = "取消",
  String sureBtn = "确定",
  Color sureColor = Colors.blue,
  Callback? onTap,
  bool isOnlySureBtn = false,
  bool barrierDismissible = true,
  double? width,
}) async {
  showDialog(
    context: context,
    barrierDismissible: barrierDismissible,
    builder: (_) {
      return Material(
        type: MaterialType.transparency,
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Container(
              decoration: new BoxDecoration(
                borderRadius: new BorderRadius.circular(12),
                gradient: new LinearGradient(
                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                    colors: [Color(0xffe0e0e3), Color(0xffeeeaef)]),
              ),
              width: width??MediaQuery
                  .of(context)
                  .size
                  .width * 0.8,
              child: new Column(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  new Padding(
                    padding: EdgeInsets.only(top: 18, left: 30, right: 30),
                    child: new Column(
                      children: <Widget>[
                        new Text(
                          '$title',
                          textAlign: TextAlign.center,
                          style: new TextStyle(
                              color: Color(0xff030303), fontSize: 17),
                        ),
                      ],
                    ),
                  ),
                  new Container(
                    padding: EdgeInsets.symmetric(vertical: 20, horizontal: 15),
                    child: new Text(
                      '$info',
                      style:
                      new TextStyle(color: Color(0xff030303), fontSize: 13),
                    ),
                  ),
                  new Container(
                    height: 0.5,
                    margin: EdgeInsets.only(top: 10),
                    color: Color(0xff4d4d4d).withAlpha(100),
                  ),
                  new Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      if(!isOnlySureBtn) new FastButton(
                        text: '$cancelBtn',
                        width: (width??MediaQuery
                            .of(context)
                            .size
                            .width) * 0.4 - 1,
                        style: new TextStyle(color: Colors.grey),
                        onTap: () {
                          Navigator.pop(context);
                          if (onTap != null) {
                            onTap(false);
                          }
                        },
                      ),
                      if(!isOnlySureBtn) new Container(
                        width: 0.5,
                        height: 45,
                        color: Color(0xff4d4d4d).withAlpha(100),
                      ),
                      new FastButton(
                        text: '$sureBtn',
                        width: isOnlySureBtn ? (width??MediaQuery
                            .of(context)
                            .size
                            .width) * 0.8 : (width??MediaQuery
                            .of(context)
                            .size
                            .width) * 0.4 - 1,
                        style: new TextStyle(color: sureColor),
                        onTap: () {
                          if (onTap != null) {
                            Navigator.pop(context);
                            onTap(true);
                          }
                        },
                      ),
                    ],
                  )
                ],
              ),
            ),
          ],
        ),
      );
    },
  );
}