fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
915 stars 515 forks source link

Issue with running web version on my flutter app with flutter_downloader #884

Closed evan8133 closed 1 year ago

evan8133 commented 1 year ago

Description:

My Flutter application is designed to seamlessly function across both mobile and web platforms. While I have successfully integrated the Flutter Downloader package, I have encountered a challenge. Although the mobile version operates flawlessly, I am currently facing an obstacle with the web version, as it refuses to run. Your assistance in resolving this web-specific issue would be greatly appreciated.

Expected Behavior

The intended functionality for my application involves enabling a download feature exclusively for the mobile platform, while excluding this feature for the web platform. I had assumed that by utilizing a package intended solely for mobile use, I could easily hide the download button when the application runs on the web.

This is my error log

Launching lib\main.dart on Edge in debug mode...
main.dart:1
This app is linked to the debug service: ws://127.0.0.1:60595/SpKN4cj70W8=/ws
Debug service listening on ws://127.0.0.1:60595/SpKN4cj70W8=/ws
Connecting to VM Service at ws://127.0.0.1:60595/SpKN4cj70W8=/ws
The webOnlyWarmupEngine API is deprecated and will be removed in a future release. Please use `bootstrapEngine` from `dart:ui_web` instead.
The webOnlySetPluginHandler API is deprecated and will be removed in a future release. Please use `setPluginHandler` from `dart:ui_web` instead.
[🌎 Easy Localization] [DEBUG] Localization initialized
Error: UnimplementedError
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:49  throw_
lib/ui/window.dart 181:5                                                      getCallbackHandle
packages/flutter_downloader/src/downloader.dart 55:38                         initialize
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54            runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5            _async
packages/flutter_downloader/src/downloader.dart 44:33                         initialize
packages/kleely/main.dart 35:27                                               main$
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50            <fn>
dart-sdk/lib/async/zone.dart 1661:54                                          runUnary
dart-sdk/lib/async/future_impl.dart 156:18                                    handleValue
dart-sdk/lib/async/future_impl.dart 840:44                                    handleValueCallback
dart-sdk/lib/async/future_impl.dart 869:13                                    _propagateToListeners
dart-sdk/lib/async/future_impl.dart 641:5                                     [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 715:7                                     callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:15           <fn>
The debugEmulateFlutterTesterEnvironment getter is deprecated and will be removed in a future release. Please use `debugEmulateFlutterTesterEnvironment` from `dart:ui_web` instead.
Restarted application in 310ms.
Error: UnimplementedError
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:49  throw_
lib/ui/window.dart 181:5                                                      getCallbackHandle
packages/flutter_downloader/src/downloader.dart 55:38                         initialize
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54            runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5            _async
packages/flutter_downloader/src/downloader.dart 44:33                         initialize
packages/kleely/main.dart 35:27                                               main$
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50            <fn>
dart-sdk/lib/async/zone.dart 1661:54                                          runUnary
dart-sdk/lib/async/future_impl.dart 156:18                                    handleValue
dart-sdk/lib/async/future_impl.dart 840:44                                    handleValueCallback
dart-sdk/lib/async/future_impl.dart 869:13                                    _propagateToListeners
dart-sdk/lib/async/future_impl.dart 641:5                                     [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 715:7                                     callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:15           <fn>
The debugEmulateFlutterTesterEnvironment getter is deprecated and will be removed in a future release. Please use `debugEmulateFlutterTesterEnvironment` from `dart:ui_web` inst

This is my version:

Flutter 3.13.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision efbf63d9c6 (6 days ago) • 2023-08-15 21:05:06 -0500
Engine • revision 1ac611c64e
Tools • Dart 3.1.0 • DevTools 2.25.0

pubspec.yaml:

name: kleely
description: A new Flutter project.
publish_to: "none"
version: 0.1.0
android_package: com.kleelycom.kleely

environment:
  sdk: ">=2.19.6 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # firebase
  firebase_core: ^2.15.0
  firebase_auth: ^4.7.1
  cloud_firestore: ^4.8.3
  firebase_storage: ^11.2.5

  # other
  http: ^0.13.6
  intl: ^0.18.0
  permission_handler: ^10.4.3
  dartz:

  # route
  path_provider: ^2.1.0
  auto_route: ^5.0.2

  # Generators
  username_generator: ^1.3.0
  uuid: ^3.0.7

  # style
  flex_color_scheme: ^7.0.5
  flutter_carousel_widget: ^2.0.4
  flutter_screenutil: ^5.7.0
  flutter_spinkit: ^5.2.0
  google_fonts: ^4.0.4
  shimmer: ^3.0.0
  curved_navigation_bar: ^1.0.3
  percent_indicator: ^4.2.3
  infinite_carousel: ^1.0.2
  intl_phone_number_input: ^0.7.3+1
  loading_animation_widget: ^1.2.0+4
  widget_and_text_animator: ^1.0.0

  # localization
  easy_localization: ^3.0.2

  # network and overlay
  connectivity_plus: ^4.0.2
  overlay_support: ^2.1.0

  # video and image
  appinio_video_player: ^1.2.1
  image_picker: ^1.0.2
  image_cropper: ^1.4.1
  flutter_downloader: ^1.11.1

  # storage
  hive: ^2.2.3
  hive_flutter: ^1.1.0

  # state management & dependency injection
  get: ^4.6.5
  get_it: ^7.6.0
  bloc: ^8.1.2
  flutter_bloc: ^8.1.3
  provider: ^6.0.5
  blurry_modal_progress_hud: ^1.1.1
  firebase_performance: ^0.9.2+5

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.0
  auto_route_generator: ^5.0.2
  build_runner: ^2.3.3
  flutter_launcher_icons: ^0.13.1
  hive_generator: ^2.0.1

flutter_icons:
  android: true
  ios: true
  image_path: "assets/logos/icon.png"

# For information on the generic Dart part of this file, see the
flutter:
  uses-material-design: true

  assets:
    - assets/logos/KleeliLogo.png
    - assets/logos/KleeliIcon.ico
    - assets/icons/1.png
    - assets/icons/2.png
    - assets/icons/3.png
    - assets/icons/4.png
    - assets/icons/biology.png
    - assets/icons/chemistry.png
    - assets/icons/physics.png
    - assets/icons/math.png
    - assets/translations/
    - assets/images/c.jpg
    - assets/audio/loading.mp3
tigranvardanyan13 commented 1 year ago

I have the same issue but I'm not using flutter_downloader

salmaahhmed commented 1 year ago

@evan8133 do you use initialize if it's a mobile device only or do you run initialize regardless of device type in the main function?

evan8133 commented 1 year ago

I have solved the issue by only initializing if its web:

    if (!kIsWeb) {
      await FlutterDownloader.initialize();
    }