Fork me on GitHub

Flutter - Error: 'xxx' is imported from both package...

Compiler message:
lib/main.dart:77:32: Error: 'Toast' is imported from both
'package:easy_alert/src/provider.dart' and 
'package:fluttertoast/fluttertoast.dart'.
toastLength: Toast.LENGTH_LONG);

 

由于引用的"Toast"同时存在于package  easy_alert fluttertoast中,编译器不确定到底是引用的哪一个包中的Toast,因此报错。

 

解决方法:

import 'package:easy_alert/easy_alert.dart' as easyAlertV;
import 'package:fluttertoast/fluttertoast.dart' as flutterToastV;

然后

flutterToastV.Fluttertoast.showToast(msg: "数据存储成功",
                    toastLength: flutterToastV.Toast.LENGTH_SHORT,
                    gravity: flutterToastV.ToastGravity.BOTTOM,
                    timeInSecForIos: 1
                  );

 

 

 

原文参考我的Stackoverflow https://stackoverflow.com/questions/53359139/error-toast-is-imported-from-both-packageeasy-alert-src-provider-dart-and

 

posted @ 2018-11-19 11:17  猫叔Vincent  阅读(2133)  评论(0编辑  收藏  举报