//import 'package:oktoast/oktoast.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:flutter/material.dart'; import 'package:liftmanager/utils/loading_dialog.dart'; /// Toast工具类 //class Toast { // static show(String msg, {duration = 2000}) { // if (msg == null){ // return; // } // showToast( // msg, // duration: Duration(milliseconds: duration), // dismissOtherToast: true // ); // } // // static cancelToast() { // dismissAllToast(); // } //} toasts(String msg,{int timeInSecForIos}) { Fluttertoast.showToast( msg: msg, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIos: timeInSecForIos); } showSnackBar(BuildContext context, String msg){ Scaffold.of(context) .showSnackBar(SnackBar(content: Text('$msg'))); } showLoading(BuildContext context, [String msg = '加载中...']) { showDialog( context: context, //BuildContext对象 barrierDismissible: false, builder: (BuildContext context) { return LoadingDialog( //调用对话框 text: msg, ); }); } showAlert(BuildContext context, String title, String content, String txt1, Function onPre1, {String txt2 = "", Function onPre2,String txt3 = "", Function onPre3,}) { showDialog( barrierDismissible: false, context: context, builder: (context) => new AlertDialog( title: new Text('${title}'), content: new Text('${content}'), actions: [ txt3.length > 0 ? new FlatButton( onPressed: onPre3, child: new Text("${txt3}"), ) : Container(), txt2.length > 0 ? new FlatButton( onPressed: onPre2, child: new Text("${txt2}"), ) : Container(), new FlatButton( onPressed: onPre1, child: new Text('${txt1}'), ), ], ), ); } dismissLoading(BuildContext context) { Navigator.pop(context); }