The App Crashes When Using FlutterDownloader.initialize() with flutter_downloader
2020-02-12 06:35 (6 years ago)

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
Please rate this article (No signup or login required)
Currently unrated
Related posts
Downgrading Flutter SDK to Version 1.x
When Running `flutter build apk`, Gradle Task `assembleRelease` Failed with Exit Code 1 and APK is Not Created
How to Communicate with a Server Using a Self-Signed Certificate (My Own CA) Without Errors in Flutter's HTTP Client
Building an Android App with Flutter and Enabling App Launch from https:// URLs Using AppLinks
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.