删除多余toast

This commit is contained in:
魏少阳 2024-01-16 16:52:35 +08:00
parent 62cbd0e570
commit db4978fbbd

View File

@ -1,122 +0,0 @@
/*
*
* author
* */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart' as ToastPlugins;
class Toast{
///
/// msg:
/// gravity
static show({required String msg,ToastPlugins.ToastGravity? gravity}){
ToastPlugins.Fluttertoast.showToast(
msg: msg,
toastLength: ToastPlugins.Toast.LENGTH_SHORT,
gravity: gravity??ToastPlugins.ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.black,
textColor: Colors.white,
fontSize: 16.0
);
}
///
///
static hidden(){
ToastPlugins.Fluttertoast.cancel();
}
///
/// context:
/// title
/// content
/// confirmText
/// confirmTextColor const Color(0xFFEE4A42)
/// cancelText
/// showCancel
/// success:
/// fail:
static showModal({
required BuildContext context,
required String title,
required String content,
required String confirmText,
required Function success,
Color? confirmTextColor,
String? cancelText,
bool? showCancel,
Function? fail
}){
confirmTextColor ??= const Color(0xFFE37549);
showCancel ??= true;
cancelText ??= '取消';
showDialog(context: context, builder: (cxt){
return AlertDialog(
buttonPadding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
contentPadding: EdgeInsets.fromLTRB( 55.w, 45.w, 55.w, 70.w),
title: Text(title,textAlign: TextAlign.center,style: TextStyle(
fontSize: 32.sp,
color: const Color(0xff26313B),
fontWeight:FontWeight.w400
)),
content: Text(content,style: TextStyle(
fontSize: 28.sp,
color: const Color(0xff666666),
fontWeight:FontWeight.w400
)),
actions: <Widget>[
Container(
width: double.infinity,
decoration: BoxDecoration(
border: Border(
top: BorderSide(
width: 1.w,//
color: const Color(0xFFEEEEEE), //
),
)
),
child: Row(
children: [
showCancel==true?Expanded(child: GestureDetector(
child: Container(
height: 90.w,
alignment: Alignment.center,
child: Text(cancelText!,textAlign: TextAlign.center,style: TextStyle(
fontSize: 28.sp
)),
),
onTap: (){
Navigator.of(cxt).pop();
if(fail!=null){
fail();
}
},
)):const SizedBox(width: 0,height: 0),
showCancel==true?Container(width: 1.w,height: 60.w,color: const Color(0xffEEEEEE)):const SizedBox(width: 0,height: 0),
Expanded(child: GestureDetector(
child: Container(
height: 90.w,
alignment: Alignment.center,
child: Text(confirmText,textAlign: TextAlign.center,style: TextStyle(
fontSize: 28.sp,
color: confirmTextColor
)),
),
onTap: (){
Navigator.of(cxt).pop();
if(success!=null){
success();
}
},
)),
],
),
)
],
);
});
}
}