0
点赞
收藏
分享

微信扫一扫

Flutter之Toast的使用

女侠展昭 2022-06-16 阅读 112

1.在pubspec.yaml中加入依赖

fluttertoast: ^3.0.3

2.更新依赖

3.导入依赖

import 'package:fluttertoast/fluttertoast.dart';

4.在common.dart中实现显示Toast的函数,然后调用即可。

showErrorToast(String msg){
Fluttertoast.showToast(
msg:msg,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIos: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
}

showCorrectToast(String msg){
Fluttertoast.showToast(
msg:msg,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIos: 1,
backgroundColor: Colors.green,
textColor: Colors.white,
fontSize: 16.0
);
}

 


举报

相关推荐

0 条评论