首先引入依賴
fluttertoast: ^2.1.1
packages get
建立Toast.dart文件,寫入如下內(nèi)容
import 'package:fluttertoast/fluttertoast.dart';
class Toast {
static show(String msg) {
Fluttertoast.showToast(msg: msg);
}
}
使用時先導(dǎo)入創(chuàng)建的dart文件吼驶,就可以愉快的使用啦!
Toast.show('hello world');