While using flutter_downloader 1.3.4 in Flutter,
In the main function:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterDownloader.initialize();
return runApp(MyApp());
}
When launching from Android Studio for debugging, the app crashes at await FlutterDownloader.initialize();
.
However, the app does not crash when launched from XCode.
Additionally, it doesn't occur when stepping through the code line by line.
Not knowing how to resolve this, I tried:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Future.delayed(Duration(milliseconds: 10)); // ← This line
await FlutterDownloader.initialize();
return runApp(MyApp());
}
After adding this, the app no longer crashes.
I don't think this is the proper solution, but I will proceed with this for the evaluation of flutter_downloader.
If anyone knows the proper way to handle this, please let me know. @ytyng
Comments