The App Crashes When Using FlutterDownloader.initialize() with flutter_downloader

2020-02-12 15:35 (5 years ago) ytyng

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

Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Archive

2025
2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011