flutter_downloader提示 FlutterDownloader.initialize() must be called first
如果使用flutter_downloader的时候提示FlutterDownloader.initialize() must be called first 具体错误如下:
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: 'package:flutter_downloader/src/downloader.dart': Failed assertion: line
73 pos 12: '_initialized': FlutterDownloader.initialize() must be called first
解决方法请参考: https://github.com/fluttercommunity/flutter_downloader/issues/354
在flutter_downloader最新版本1.5.2中我们还需要在main.dart中初始化FlutterDownloader,详情见main.dart
import 'package:flutter_downloader/flutter_downloader.dart';
const debug = true; //表示是否在控制台显示调试信息
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterDownloader.initialize(debug: debug);
runApp(new MyApp());
}
更多关于flutter_downloader提示 FlutterDownloader.initialize() must be called first的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html