deakjahn / flutter_dropzone

A drag-and-drop Flutter plugin (Web). Only web and only from outside into Flutter.
https://pub.dev/packages/flutter_dropzone
85 stars 36 forks source link

The platformViewRegistry getter is deprecated and will be removed in a future release. Please import it from `dart:ui_web` instead. #73

Closed tushar0518 closed 5 months ago

tushar0518 commented 6 months ago

I'm getting the below warning when using the dropzone package. @deakjahn

Warnings: The platformViewRegistry getter is deprecated and will be removed in a future release. Please import it from dart:ui_web instead. The webOnlyAssetManager getter is deprecated and will be removed in a future release. Please use assetManager from dart:ui_web instead.

Possible Fix: change this import => import 'dart:ui' as ui; to import 'dart:ui_web' as ui; throughout the project

Flutter Doctor: Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.16.7, on macOS 13.3 22E252 darwin-x64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.1) [✓] VS Code (version 1.85.1)

JorgeBrandao1980 commented 5 months ago

Good morning. I have exactly the same problem, have you found a solution yet? Thank you.

tushar0518 commented 5 months ago

Good morning. I have exactly the same problem, have you found a solution yet? Thank you.

not at the moment, if only the author of the plugin should make the changes and release a new version.

deakjahn commented 5 months ago

@tushar0518 Yes, yes, I hear. But this is always a double edged sword. Flutter introduces something new and deprecates the old one. People who upgrade their Flutter immediately are annoyed by the warning. But other people who don't upgrade might find their existing, functioning plugins suddenly broken. It's always a tough decision to determine how long to wait. Now that we moved, we might get an influx of angry people reporting that the plugin no longer works for them just because they still use a Flutter version of a year ago. :-))

ztaylor54 commented 5 months ago

<...> we might get an influx of angry people reporting that the plugin no longer works for them just because they still use a Flutter version of a year ago. :-))

@deakjahn here with my pitchfork 😅

This is a non-issue with proper use of version constraints in your pubspec.yaml. At the very least, it should be a new major version, which would indicate a breaking change and prevent a flutter pub upgrade from upgrading versions automatically (hence why I'm here). See this stack overflow answer for more context / info.

The release notes for 3.13.0 show the addition of the deprecation message to the dart:ui package, so you'd probably be OK updating the pubcpec.yaml with:

environment:
  sdk: ">=2.12.0 <4.0.0"
  flutter: ">=3.13.0"

The temporary workaround on my end (and for anyone else who comes across this) is to override the version for flutter_dropzone_web in pubspec.yaml:

dependency_overrides:
  flutter_dropzone_web: <=3.0.12

or upgrade to a version of flutter >= 3.13.

deakjahn commented 5 months ago

Yes, for serious changes, for sure. But to create a major version change for something as small as a deprecation, well. :-)

ztaylor54 commented 5 months ago

@deakjahn I would agree if it were just a deprecation - but your change depends on dart:ui_web:

https://github.com/deakjahn/flutter_dropzone/blob/feb34bdc20165ec9eadba6ae11737bcfd03512e1/flutter_dropzone_web/lib/flutter_dropzone_plugin.dart#L3

dart:ui_web was introduced in Flutter version 3.10.0 (see the release notes and PR) and platformViewRegistry wasn't moved into ui_web until version 3.13.0 (see my above comment), but the pubspec.yaml only requires >=1.17.0:

https://github.com/deakjahn/flutter_dropzone/blob/feb34bdc20165ec9eadba6ae11737bcfd03512e1/flutter_dropzone_web/pubspec.yaml#L8

This is a breaking / major change if you don't keep your version constraints up-to-date. In fact, this package is currently broken for any news users that don't have at least flutter version 3.13.0 installed. It causes the following compilation error:

../../../../.pub-cache/hosted/pub.dev/flutter_dropzone_web-3.0.13/lib/flutter_dropzone_plugin.dart:27:8: Error: Undefined name 'platformViewRegistry'.
    ui.platformViewRegistry.registerViewFactory(
       ^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/flutter_dropzone_web-3.0.13/lib/flutter_dropzone_plugin.dart:33:26: Error: Undefined name 'assetManager'.
    final scriptUrl = ui.assetManager.getAssetUrl(

You should at the very least update the pubspec.yaml to include the proper constraints in the next release.

deakjahn commented 5 months ago

@ztaylor54 I added it. The reason I'm a bit unwilling to make it a breaking change right now is that a new version is in the works (see https://github.com/deakjahn/flutter_dropzone/pull/76) that we're forced to do, anyway, because of underlying changes in Flutter. And that will be a breaking change and a new major version for sure*. Unfortunately for us, Flutter is doing very active work in this department now and this makes it a bit of a moving target. Also, I have the feeling that this new approach with the web package in not as mature yet as the Flutter team makes it out to be. I'm afraid we'll have some serious bumps on this road, no matter what.

(* In hindsight, we could have postponed this change here until that new version but unfortunately, the timeline was different, this change was already done when the new issue emerged.)

This new change will have much more serious implications, as consumers will need to move on to the new package as well, so this will really warrant a new major version. But developers lagging behind the current Flutter version, well... As I mentioned above, I'm never really comfortable doing it right away, but four or five months after the actual upgrade came out, well, I'm inclined to think that everybody should already be moving along. At any rate, modifying the constraint is absolutely warranted, sure.

I made a pinned issue now for people arriving with the old version, also mentioning that a new version will be out later.