Flutter中实现安卓中的弹toast提示的功能。
- 在
pubspec.yaml
文件的dependencies
中添加库fluttertoast: ^2.1.1
- 在
pubspec.yaml
文件中右上角处点击Packages get
- 在需要使用的文件内导入包
import 'package:fluttertoast/fluttertoast.dart';
- 使用,示例如下:
Fluttertoast.showToast(
msg: "Hello Jason",
toastLength: Toast.LENGTH_SHORT, // 默认为LENGTH_SHORT,可改为LENGTH_LONG
gravity: ToastGravity.BOTTOM, // 默认为bottom,显示在底部,可改为居中或头部
timeInSecForIos: 2, // iOS系统上显示时长,默认为1,单位s
backgroundColor: Colors.red, // 背景色,默认为黑色
textColor: Colors.white); // 文字颜色,默认为白色