extended_image
extended_image copied to clipboard
[Bug report] Cannot compile to web due to conflicting File class
Version
8.2.0
Platforms
Web
Device Model
Windows PC
flutter info
[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.19045.4170], locale sv-SE)
• Flutter version 3.19.5 on channel stable at C:\tools\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 300451adae (3 weeks ago), 2024-03-27 21:54:07 -0500
• Engine revision e76c956498
• Dart version 3.3.3
• DevTools version 2.31.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.3)
• Visual Studio at E:\Software\VisualStudio\2022
• Visual Studio Community 2022 version 17.7.34024.191
• Windows 10 SDK version 10.0.22621.0
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[√] VS Code (version 1.88.1)
• VS Code at C:\Users\Lechuck\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.86.0
[√] VS Code, 64-bit edition (version 1.88.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.86.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.4170]
• Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.124
• Edge (web) • edge • web-javascript • Microsoft Edge 120.0.2210.61 (unsupported)
[√] Network resources
• All expected network resources are available.
! Doctor found issues in 2 categories.
How to reproduce?
- Import ExtendedImage & File from dart:io
- Use File class with ExtendedImage.file
- Export to web (chrome)
Logs
[ +327 ms] Unable to locate an Android SDK.
[ +222 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +113 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ +6 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +78 ms] Initializing file store
[ +2 ms] Done initializing file store
[ +18 ms] Skipping target: gen_localizations
[ +2 ms] Persisting file store
[ +4 ms] Done persisting file store
[ +11 ms] Skipping pub get: version match.
[ +56 ms] Found plugin device_info_plus at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\device_info_plus-10.1.0\
[ +16 ms] Found plugin file_picker at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\file_picker-8.0.0+1\
[ +6 ms] Found plugin flutter_plugin_android_lifecycle at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_plugin_android_lifecycle-2.0.19\
[ +11 ms] Found plugin irondash_engine_context at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\irondash_engine_context-0.5.2\
[ +28 ms] Found plugin path_provider at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider-2.1.3\
[ +13 ms] Found plugin path_provider_android at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_android-2.2.4\
[ +3 ms] Found plugin path_provider_foundation at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_foundation-2.3.2\
[ +3 ms] Found plugin path_provider_linux at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_linux-2.2.1\
[ +6 ms] Found plugin path_provider_windows at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_windows-2.2.1\
[ +31 ms] Found plugin super_native_extensions at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\super_native_extensions-0.8.11\
[ +65 ms] Found plugin device_info_plus at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\device_info_plus-10.1.0\
[ +9 ms] Found plugin file_picker at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\file_picker-8.0.0+1\
[ +5 ms] Found plugin flutter_plugin_android_lifecycle at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_plugin_android_lifecycle-2.0.19\
[ +10 ms] Found plugin irondash_engine_context at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\irondash_engine_context-0.5.2\
[ +19 ms] Found plugin path_provider at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider-2.1.3\
[ +1 ms] Found plugin path_provider_android at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_android-2.2.4\
[ +4 ms] Found plugin path_provider_foundation at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_foundation-2.3.2\
[ +3 ms] Found plugin path_provider_linux at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_linux-2.2.1\
[ +3 ms] Found plugin path_provider_windows at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_windows-2.2.1\
[ +15 ms] Found plugin super_native_extensions at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\super_native_extensions-0.8.11\
[ +53 ms] Found plugin device_info_plus at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\device_info_plus-10.1.0\
[ +6 ms] Found plugin file_picker at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\file_picker-8.0.0+1\
[ +2 ms] Found plugin flutter_plugin_android_lifecycle at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_plugin_android_lifecycle-2.0.19\
[ +4 ms] Found plugin irondash_engine_context at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\irondash_engine_context-0.5.2\
[ +11 ms] Found plugin path_provider at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider-2.1.3\
[ +1 ms] Found plugin path_provider_android at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_android-2.2.4\
[ +1 ms] Found plugin path_provider_foundation at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_foundation-2.3.2\
[ +1 ms] Found plugin path_provider_linux at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_linux-2.2.1\
[ +4 ms] Found plugin path_provider_windows at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_windows-2.2.1\
[ +16 ms] Found plugin super_native_extensions at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\super_native_extensions-0.8.11\
[ +111 ms] Generating D:\Programming\Flutter\gazou\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[ +118 ms] Launching lib\main.dart on Chrome in debug mode...
[ +90 ms] Initializing file store
[ +5 ms] gen_localizations: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents:
C:\tools\flutter\packages\flutter_tools\lib\src\build_system\targets\localizations.dart,D:\Programming\Flutter\gazou\l10n.yaml,D:\Programming\Flutter\project\lib/src/localization\app_en.arb,D:\Programming\Flutter\project\.dart_tool\flutter_gen\gen_l10n\app_localizations_en.dart,D:\Programming\Flutter\gazou\.dart_tool\flutter_gen\gen_l10n\app_localizations.dart}
[ +102 ms] Skipping target: gen_dart_plugin_registrant
[ +2 ms] gen_localizations: Complete
[ +2 ms] Skipping target: _composite
[ +2 ms] complete
[ +1 ms] Updating assets
[ +141 ms] Manifest contained wildcard assets. Inserting missing file into build graph to force rerun. for more information see #56466.
[ +9 ms] Waiting for connection from debug service on Chrome...
[ +21 ms] Found plugin device_info_plus at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\device_info_plus-10.1.0\
[ +13 ms] Found plugin file_picker at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\file_picker-8.0.0+1\
[ +6 ms] Found plugin flutter_plugin_android_lifecycle at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_plugin_android_lifecycle-2.0.19\
[ +7 ms] Found plugin irondash_engine_context at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\irondash_engine_context-0.5.2\
[ +12 ms] Found plugin path_provider at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider-2.1.3\
[ +1 ms] Found plugin path_provider_android at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_android-2.2.4\
[ +1 ms] Found plugin path_provider_foundation at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_foundation-2.3.2\
[ +2 ms] Found plugin path_provider_linux at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_linux-2.2.1\
[ +2 ms] Found plugin path_provider_windows at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_windows-2.2.1\
[ +20 ms] Found plugin super_native_extensions at C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dev\super_native_extensions-0.8.11\
[ +45 ms] shaderc command: [C:\tools\flutter\bin\cache\artifacts\engine\windows-x64\impellerc.exe, --sksl, --iplr, --json, --sl=build\flutter_assets\shaders/ink_sparkle.frag,
--spirv=build\flutter_assets\shaders/ink_sparkle.frag.spirv, --input=C:\tools\flutter\packages\flutter\lib\src\material\shaders\ink_sparkle.frag, --input-type=frag,
--include=C:\tools\flutter\packages\flutter\lib\src\material\shaders, --include=C:\tools\flutter\bin\cache\artifacts\engine\windows-x64\shader_lib]
[ +250 ms] <- reset
[ +4 ms] C:\tools\flutter\bin\cache\dart-sdk\bin\dartaotruntime.exe --disable-dart-dev C:\tools\flutter\bin\cache\dart-sdk\bin\snapshots\frontend_server_aot.dart.snapshot --sdk-root
C:\tools\flutter\bin\cache\flutter_web_sdk/ --incremental --target=dartdevc --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true
-DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/e76c956498841e1ab458577d3892003e553e4f3c/ --output-dill E:\TEMP\WIN\flutter_tools.eb96bc5\flutter_tool.3585df93\app.dill
--packages D:\Programming\Flutter\gazou\.dart_tool\package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-root
E:\TEMP\WIN\flutter_tools.eb96bc5\flutter_tools.96a0e20b --filesystem-scheme org-dartlang-app --initialize-from-dill build\baeeb1a37f580af27b2a863b23591623.cache.dill.track.dill --platform
file:///C:/tools/flutter/bin/cache/flutter_web_sdk/kernel/ddc_outline_sound.dill --verbosity=error --sound-null-safety
[ +9 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+5673 ms] lib/src/image/minimap.dart:56:15: Error: The argument type 'File/*1*/' can't be assigned to the parameter type 'File/*2*/'.
[ +1 ms] - 'File/*1*/' is from 'dart:io'.
[ ] - 'File/*2*/' is from 'package:extended_image_library/src/_platform_web.dart'
('/C:/Users/Username/AppData/Local/Pub/Cache/hosted/pub.dev/extended_image_library-4.0.4/lib/src/_platform_web.dart').
[ +2 ms] File("E:\\Image\\image.png"),
[ ] ^
[ ] lib/src/test.dart:19:14: Error: The argument type 'File/*1*/' can't be assigned to the parameter type 'File/*2*/'.
[ ] - 'File/*1*/' is from 'dart:io'.
[ ] - 'File/*2*/' is from 'package:extended_image_library/src/_platform_web.dart'
('/C:/Users/Username/AppData/Local/Pub/Cache/hosted/pub.dev/extended_image_library-4.0.4/lib/src/_platform_web.dart').
[ +1 ms] widget.imageFile,
[ ] ^
[+18667 ms] Waiting for connection from debug service on Chrome... (completed in 24,7s)
[ +1 ms] Synced 0.0MB.
[ ] Failed to compile application.
[ +4 ms] "flutter run" took 26 048ms.
[ +3 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:815:9)
<asynchronous suspension>
#2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1389:27)
<asynchronous suspension>
#3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#4 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#5 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:355:9)
<asynchronous suspension>
#6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:295:5)
<asynchronous suspension>
#8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:119:9)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#10 main (package:flutter_tools/executable.dart:90:3)
<asynchronous suspension>
[ +4 ms] Running 1 shutdown hook
[ +14 ms] Shutdown hooks complete
[ +3 ms] exiting with code 1
Example code (optional)
import 'dart:io';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
class TestExtendImage extends StatefulWidget {
final File imageFile;
const TestExtendImage({super.key, required this.imageFile});
@override
State<TestExtendImage> createState() => _TestExtendImageState();
}
class _TestExtendImageState extends State<TestExtendImage> {
@override
Widget build(BuildContext context) {
return ExtendedImage.file(
widget.imageFile,
fit: BoxFit.contain,
//enableLoadState: false,
mode: ExtendedImageMode.gesture,
initGestureConfigHandler: (state) {
return GestureConfig(
minScale: 0.9,
animationMinScale: 0.7,
maxScale: 10.0,
animationMaxScale: 10.5,
speed: 0.90,
inertialSpeed: 100.0,
initialScale: 1.0,
inPageView: false,
reverseMousePointerScrollDirection: true,
initialAlignment: InitialAlignment.center,
);
},
);
}
}
// main.dart
import 'package:project/src/image/test.dart';
class Root extends StatelessWidget {
const Root({super.key});
static const routeName = '/';
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (context) => FitProvider(),
child: Scaffold(
body: Container(
color: Colors.blue,
padding: const EdgeInsets.all(9),
width: double.infinity,
height: double.infinity,
child: TestExtendImage(File("E:\\Image\\image.png"))),
));
}
}
Contact
No response
File is not support on web, you should make some Platform Code Separation like
https://github.com/fluttercandies/extended_image_library/blob/33422e7f5fbc755c6ec63cf0741cabd0f71cd2cf/lib/src/platform.dart#L11
Thanks for the response! I realized that too after some searching around, however when I was querying folks on the Flutter discord they pointed out: "They don't provide a public common interface for cross-file, yet they don't use XFile from the cross_file package", which is what the issue was intended to be about.
ExtendedImage.file corresponds to Image.file , this package will not to be changed before Image.file use XFile
Ah that's fair, then I assume I shouldn't worry about extend_image's own File class?
Perhaps I can implement the [File Class] (https://github.com/fluttercandies/extended_image_library/blob/33422e7f5fbc755c6ec63cf0741cabd0f71cd2cf/lib/src/_platform_web.dart#L7) based on cross_file.