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

fix: get script url using flutter utility #65

Closed p-mazhnik closed 1 year ago

p-mazhnik commented 1 year ago

In Flutter it is possible to customize the location that assets will be loaded from (e.g. using assetBase meta tag or providing this property to engine initializer directly) Current solution assumes that script is always under <rootUrl>/assets/ directory, which is not true if assetBase is used. So in the current PR I use getAssetUrl utility provided by Flutter that respects assetBase

https://github.com/flutter/engine/blob/942909b77001b4904e26aa29e3cac63345108a0a/lib/web_ui/lib/ui_web/src/ui_web/asset_manager.dart#L76-L81

deakjahn commented 1 year ago

The pubspec.yaml has a specific reference to the asset file. Do you think this has any influence on this issue?

p-mazhnik commented 1 year ago

No, this is only to locate asset within the package: pathInPackage = packages/flutter_dropzone_web/assets/flutter_dropzone.js.

Current issue is that code assumes that url for this asset within the app will be assets/ + $pathInPackage = assets/packages/flutter_dropzone_web/assets/flutter_dropzone.js, which is not always true, because it can be $assetBase + assets/ + $pathInPackage. That is what getAssetUrl utility is for:

getAssetUrl(pathInPackage) => $assetBase + $assetsDirectory + $pathInPackage

deakjahn commented 1 year ago

Let's see, thanks.