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

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

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
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive