Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load' #270

Closed
xiaodeng2014 opened this issue Oct 18, 2019 · 47 comments

Comments

@xiaodeng2014
Copy link

When I use the latest version of flutter, the following error will be reported when I introduce this library

Compiler message:
../../../../macLib/flutter/.pub-cache/hosted/pub.flutter-io.cn/cached_network_image-1.1.2+1/lib/src/cached_network_image_provider.dart:53:24: Error: The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of
overridden method 'ImageProvider.load'.
ImageStreamCompleter load(CachedNetworkImageProvider key) {
^
../../../../macLib/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
^
../../../../macLib/flutter/.pub-cache/hosted/pub.flutter-io.cn/cached_network_image-1.1.2+1/lib/src/scaled_file_image.dart:45:24: Error: The method 'ScaledFileImage.load' has fewer positional arguments than those of overridden method
'ImageProvider.load'.
ImageStreamCompleter load(ScaledFileImage key) {
^
../../../../macLib/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
^
Exception: Errors during snapshot creation: null
#0 KernelSnapshot.build (package:flutter_tools/src/build_system/targets/dart.dart:225:7)

#1 _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:526:25)

#2 _BuildInstance.invokeTarget. (package:flutter_tools/src/build_system/build_system.dart:481:35)
#3 new Future.sync (dart:async/future.dart:224:31)
#4 AsyncMemoizer.runOnce (package:async/src/async_memoizer.dart:43:45)
#5 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:481:21)


#6 BuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:419:36)
#7 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#8 BuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:400:28)
#9 buildWithAssemble (package:flutter_tools/src/bundle.dart:122:48)
#10 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#11 buildWithAssemble (package:flutter_tools/src/bundle.dart:98:31)
#12 BundleBuilder.build (package:flutter_tools/src/bundle.dart:75:11)
#13 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#14 BundleBuilder.build (package:flutter_tools/src/bundle.dart:52:21)
#15 IOSSimulator._sideloadUpdatedAssetsForInstalledApplicationBundle (package:flutter_tools/src/ios/simulators.dart:453:28)
#16 IOSSimulator._setupUpdatedApplicationBundle (package:flutter_tools/src/ios/simulators.dart:420:11)
#17 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#18 IOSSimulator._setupUpdatedApplicationBundle (package:flutter_tools/src/ios/simulators.dart:419:46)
#19 IOSSimulator.startApp (package:flutter_tools/src/ios/simulators.dart:352:15)
#20 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#21 IOSSimulator.startApp (package:flutter_tools/src/ios/simulators.dart:339:32)
#22 FlutterDevice.runHot (package:flutter_tools/src/resident_runner.dart:380:54)
#23 _asyncThenWrapperHelper. (dart:async-patch/async_patch.dart:71:64)
#24 _rootRunUnary (dart:async/zone.dart:1132:38)
#25 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#26 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#27 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#28 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#29 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#30 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#31 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#32 BuildableIOSApp.fromProject (package:flutter_tools/src/application_package.dart)
#33 _asyncThenWrapperHelper. (dart:async-patch/async_patch.dart:71:64)
#34 _rootRunUnary (dart:async/zone.dart:1132:38)
#35 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#36 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#37 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#38 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#39 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#40 Future._asyncComplete. (dart:async/future_impl.dart:552:7)
#41 _rootRun (dart:async/zone.dart:1124:13)
#42 _CustomZone.run (dart:async/zone.dart:1021:19)
#43 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#44 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
#45 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#46 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#47 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#48 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)

This is my version of Flutter:

Flutter 1.10.15-pre.166 • channel master • https://github.com/flutter/flutter.git
Framework • revision 1781d5c9bb (18 minutes ago) • 2019-10-17 19:22:47 -0700
Engine • revision 508146f0de
Tools • Dart 2.6.0 (build 2.6.0-dev.8.0 f020ce5d23)

@renefloor
Copy link
Contributor

Please see the readme on the frontpage (https://github.com/renefloor/flutter_cached_network_image)
You can keep this issue open for reference, so hopefully less people open issues.

@DLErice
Copy link

DLErice commented Oct 18, 2019

I have same problem~

@renefloor
Copy link
Contributor

@DLErice So did you read the frontpage? You can download 2.0.0-rc and everything should work fine. Or just use the stable channel of Flutter....

@sumujain1995
Copy link

@renefloor when will this issue will be resolved ?

@renefloor
Copy link
Contributor

It is already solved, you just need to use 2.0.0-rc. I won't make it a stable version as long as it is only usable on master and maybe not even until flutter hits stable.

This change in flutter is a breaking change, so I can never make it backwards compatible.

@sumujain1995
Copy link

@renefloor thanks for clarifying the doubt !

@maylortaylor
Copy link

It is already solved, you just need to use 2.0.0-rc. I won't make it a stable version as long as it is only usable on master and maybe not even until flutter hits stable.

This change in flutter is a breaking change, so I can never make it backwards compatible.

How would I upgrade to cached_network_image v2.0.0-rc ?
When i moved from Flutter Stable to Flutter Dev (using command flutter channel dev then flutter channel upgrade) I was still only on Flutter SDK 1.10.7 and i was given this error when running flutter packages get

The current Flutter SDK version is 1.10.7.

Because artstumble depends on cached_network_image >=2.0.0-rc which requires Flutter SDK version >=1.10.15-pre.148 <2.0.0, version solving failed.

@renefloor
Copy link
Contributor

@maylortaylor I just tried on beta, which is on 1.10.7, but at that version cached_network_image 1.1.2 should still work. Do you have any issues with that version?

@hanabi1224
Copy link

@renefloor Looks like the breaking change has rolled out to dev channel, I just created CI build to confirm: #283

@hanabi1224
Copy link

@renefloor I have a project that currently has to target on flutter dev channel because of a hard dependency on its FFI features, and it's really annoying that breaking changes on ImageProvider APIs are introduced. I would suggest separating out the ImageProvider API as a standalone package to make the widget api work for all channels, what do you think?

@renefloor
Copy link
Contributor

@hanabi1224 It could be a solution, but I'm afraid many people won't understand what is the difference between the two and will complain that they can't use it while they actually need to other package. We just have to go through this phase of having 2 incompatible versions.

Do you also need to build the same app on more stable flutter channels? Otherwise you can just use version 2.0.0 right?

@hanabi1224
Copy link

hanabi1224 commented Nov 8, 2019

@renefloor I only need to build against flutter dev (currently 1.10.15) however 2.0.0-rc.1 does not work for me (The same error may come from some other packages tho, I will take another look to confirm) : (

@gisinator
Copy link

gisinator commented Nov 25, 2019

I just upgraded to 1.11.0 beta release and then also faced the "the method 'networkImageWithRetry.load' has fewer positional arguments..." error. Unfortunately 2.0.0-rc.1 does not solve the problem. Anything I can try? Thanks :)
/edit: My bad, the error is connected to another plugin advanced_networkimage. Sorry

@ghost
Copy link

ghost commented Nov 28, 2019

had this bug too today
i switch flutter to beta (v1.11.0) and changed this plugin to 2.0.0-rc.1 to solve this and got a bunch of gradle errors that got complected
finally i switch back to stable (1.9.1+hotfix.6) and behold the bug is gone
@renefloor thank you for this awesome plugin and all the support !!!

@mirkancal
Copy link

It's not working with the current stable release, 1.12.13+hotfix.5. Any news on this issue?

@sinanawad
Copy link

It's not working with the current stable release, 1.12.13+hotfix.5. Any news on this issue?

I just used 2.0.0-rc for now.

@aimsugita
Copy link

2.0.0-rc is not stable version

@IshankDev
Copy link

Worked for me with 2.0.0-rc

@basnetjiten
Copy link

For now it worked for me with 2.0.0-rc with latest flutter 1.12

@RobertoOFonseca
Copy link

Also, it worked for me with 2.0.0-rc with latest flutter 1.12

Modifed on pubspec.lock:
cached_network_image:
dependency: "direct dev"
description:
name: cached_network_image
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0-rc"

added on dev_dependencies, pubspec.yaml:
cached_network_image: 2.0.0-rc

@cacianokroth
Copy link

For mee too it worked 2.0.0-rc with latest flutter 1.12

@eapvisuals
Copy link

Had the same problem, after reading the README file, everything was fine again, I can proceed.
FYI I am running:

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v1.13.0, on Mac OS X 10.14.6 18G1012, locale en-IT)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.40.2)
[✓] Connected device (1 available)

@DHK0316
Copy link

DHK0316 commented Dec 12, 2019

Please see the readme on the frontpage (https://github.com/renefloor/flutter_cached_network_image)
You can keep this issue open for reference, so hopefully less people open issues.

I solved it perfectly after upgrading to cached_network_image: ^2.0.0-rc.
Thank you so much!!

@adeolaex
Copy link

Well this got a lot of traction. Worked fine after upgrading to 2.0.0-rc and the new stable version of flutter (1.12). I guess the Flutter team was right for one thing. The community is beyond great!

@Basher7
Copy link

Basher7 commented Dec 14, 2019

Also, it worked for me with 2.0.0-rc with latest flutter 1.12

Modifed on pubspec.lock:
cached_network_image:
dependency: "direct dev"
description:
name: cached_network_image
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0-rc"

added on dev_dependencies, pubspec.yaml:
cached_network_image: 2.0.0-rc

It's worked for me at Flutter: 1.12.13+hotfix.5. Thanks

@AronJorge
Copy link

Download and reinstall the flutter sdk

@malkny
Copy link

malkny commented Dec 15, 2019

[note My Flutter: 1.12.13+hotfix.5 ]
There is a problem with [ flutter_map ] try to avoid it [when I remove it from [ pubspec.yaml ] all my mistake is gone without any reinstall of flutter sdk :]

@HasseneKh
Copy link

[note My Flutter: 1.12.13+hotfix.5 ]
i have the same problem the [flutter_map] and [flutter_map_marker_cluster] depend form [cached_network_image] , i can't switch to version 2.0.0-rc

@HasseneKh
Copy link

solution :
Upgrade in Flutter_map pubspec.yaml:
flutter_image : 3.0.0
cached_network_image: 2.0.0-rc
Go to cached_network_image_provider.dart and add DecoderCallback decode, as a second parameter in CachedNetworkImageProvider.load() function
@OverRide
ImageStreamCompleter load(
CachedNetworkImageProvider key, DecoderCallback decode) {
return MultiFrameImageStreamCompleter(
codec: _loadAsync(key),
scale: key.scale,
);
}
Go to mbtiles_image_provider.dart and again add DecoderCallback decode, as a second parameter in ImageProvider.load() function
It should work for now.

@AronJorge
Copy link

AronJorge commented Dec 16, 2019

Solution

You're right, the problem is described in this post https://pub.dev/documentation/cached_network_image/latest/

Breaking change with ImageProvider.load in Flutter 1.10
The Flutter team made a breaking change with the ImageProvider in Flutter 1.10.15 (currently Master channel only).

https://pub.dev/packages/cached_network_image/versions/2.0.0-rc.1#-installing-tab-

@JCKodel
Copy link

JCKodel commented Dec 16, 2019

What should I pass to second parameter of CachedNetworkImageProvider.load?
It now requires a DecoderCallback decode, but there is no docs saying nothing about it =\

@Blasanka
Copy link

Blasanka commented Dec 23, 2019

Flutter 1.12.13+hotfix.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 27321ebbad (12 days ago) • 2019-12-10 18:15:01 -0800
Engine • revision 2994f7e1e6
Tools • Dart 2.7.0

I updated the Flutter to latest today and got this error and read the repo readme and act on it. Everything works fine now thanks to package owner Rene Floor

Just increment the package in pubspec.yaml as suggested by the owner:

cached_network_image: ^2.0.0-rc

By package owner:

Breaking change with ImageProvider.load in Flutter 1.10

The Flutter team made a breaking change with the ImageProvider in Flutter 1.10.15 (currently Master channel only).

If you are experiencing one of the following errors upgrade to 2.0.0-rc.

The method 'ScaledFileImage.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'

The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method

@ThinkDigitalSoftware
Copy link

Since we're at 1.12+ on stable, can 2.0rc be released as a regular version, @renefloor ?

@xiaodeng2014
Copy link
Author

@renefloor
Everyone knows this problem and already knows how to solve it, then I will close this problem

@deepkachchhawah
Copy link

i have same proble this type,.,, anyone can give me solution

@renefloor
Copy link
Contributor

@deepkachchhawah do you use version 2.0.0 or 1.x? It should be fixed in 2.0.0

@tonymedrano
Copy link

tonymedrano commented Apr 5, 2020

By adding DecoderCallback decode as second argument fix the problem. Upgrade to lastest.

@OverRide
ImageStreamCompleter load(CachedNetworkImageProvider key, DecoderCallback decode) {
return MultiFrameImageStreamCompleter(
codec: _loadAsync(key),
scale: key.scale,
informationCollector: () {
return [
DiagnosticsNode.message('Image provider: $this'),
DiagnosticsNode.message('Image key: $key'),
];
});
}

@4tKnight
Copy link

2.0.0-rc worked like a charm... Thanks alot

@Chimba123
Copy link

Chimba123 commented Jun 4, 2020

Please see the readme on the frontpage (https://github.com/renefloor/flutter_cached_network_image)
You can keep this issue open for reference, so hopefully less people open issues.

I have read but nothing special there what exactly is nouveau there? or significantly different from the actual implementation example given given here https://pub.dev/packages/cached_network_image

@Chimba123
Copy link

For mee too it worked 2.0.0-rc with latest flutter 1.12

for me it's not working on the current latest stable release of Flutter which is at the time of this posting 1.17.2

@renefloor
Copy link
Contributor

@Chimba123 which version of CachedNetworkImage are you using and what's the exact error you get?

@Chimba123
Copy link

I have just updated to cached_network_image: ^2.0.0-rc in the pubspec. The problem is that the placeholder in the CachedNetworkImage widget is not being replaced by the loaded images from the network it was working before but its just stuck on the loader or the blur hash

this is my code:
CachedNetworkImage( imageUrl: '${hits[index].largeImageURL}', placeholder: (context, url) => const AspectRatio( aspectRatio: 1.6, child: BlurHash(hash: 'LEHV6nWB2yk8pyo0adR*.7kCMdnj'), ), errorWidget: (context, url, error) => const Icon(Icons.refresh), fit: BoxFit.cover, ),

the blur hash widget is not fading out to show the loaded state/images

@Chimba123
Copy link

then I am also getting this error:

[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getTemporaryDirectory on channel plugins.flutter.io/path_provider)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)

#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2 MethodChannelPathProvider.getTemporaryPath (package:path_provider_platform_interface/src/method_channel_path_provider.dart:34:26)
#3 getTemporaryDirectory (package:path_provider/path_provider.dart:60:39)
#4 DefaultCacheManager.getFilePath (package:flutter_cache_manager/src/cache_manager.dart:44:27)
#5 BaseCacheManager._createFileDir (package:flutter_cache_manager/src/cache_manager.dart:254:41)
#6 BaseCacheManager._createCacheStore (package:flutter_cache_manager/src/cache_manager.dart:263:23)
#7 new BaseCacheManager (package:flutter_cache_manager/src/cache_manager.dart:84:28)
#8 <…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)

#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2 invokeMethod (package:sqflite/src/sqflite_impl.dart:17:13)
#3 SqfliteDatabaseFactoryImpl.invokeMethod (package:sqflite/src/factory_impl.dart:31:7)
#4 SqfliteDatabaseFactoryMixin.safeInvokeMethod. (package:sqflite_common/src/factory_mixin.dart:25:35)
#5 wrapDatabaseException (package:sqflite/src/exception_impl.dart:7:32)
#6 SqfliteDatabaseFactoryImpl.wrapDatabaseException (package:sqflite/src/factory_impl.dart:27:7)
#7 SqfliteDatabaseFactoryMixin.safeInvokeMethod (package:sqflite_common/src/factory_mixin.dart:25:7)
#8 SqfliteDatabaseFactoryMixin.getDatabasesPath (package:sq<…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)

#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2 invokeMethod (package:sqflite/src/sqflite_impl.dart:17:13)
#3 SqfliteDatabaseFactoryImpl.invokeMethod (package:sqflite/src/factory_impl.dart:31:7)
#4 SqfliteDatabaseFactoryMixin.safeInvokeMethod. (package:sqflite_common/src/factory_mixin.dart:25:35)
#5 wrapDatabaseException (package:sqflite/src/exception_impl.dart:7:32)
#6 SqfliteDatabaseFactoryImpl.wrapDatabaseException (package:sqflite/src/factory_impl.dart:27:7)
#7 SqfliteDatabaseFactoryMixin.safeInvokeMethod (package:sqflite_common/src/factory_mixin.dart:25:7)
#8 SqfliteDatabaseFactoryMixin.getDatabasesPath (package:sq<…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)

#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2 invokeMethod (package:sqflite/src/sqflite_impl.dart:17:13)
#3 SqfliteDatabaseFactoryImpl.invokeMethod (package:sqflite/src/factory_impl.dart:31:7)
#4 SqfliteDatabaseFactoryMixin.safeInvokeMethod. (package:sqflite_common/src/factory_mixin.dart:25:35)
#5 wrapDatabaseException (package:sqflite/src/exception_impl.dart:7:32)
#6 SqfliteDatabaseFactoryImpl.wrapDatabaseException (package:sqflite/src/factory_impl.dart:27:7)
#7 SqfliteDatabaseFactoryMixin.safeInvokeMethod (package:sqflite_common/src/factory_mixin.dart:25:7)
#8 SqfliteDatabaseFactoryMixin.getDatabasesPath (package:sq<…>

@Chimba123
Copy link

Screenshot 2020-06-04 at 8 20 29 PM

The placeholder is just stuck there... even though the state is loaded as shown by the bloc in the console as below:

flutter: onTransition Transition { currentState: SocialsFeedLoading, event: FetchSocialsFeed, nextState: SocialsFeedLoaded }
flutter: [SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel, SocialsFeedModel]

The last state is "SocialsFeedLoaded" and the model is loaded but the data is not being shown in the CacheNetwrokImage .. but it used too previously before the upgrade

@renefloor
Copy link
Contributor

But that has nothing to do with "The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'", so why do you post here as if you have this issue?

@Chimba123
Copy link

@renefloor > I have just updated to cached_network_image: ^2.0.0-rc in the pubspec I did that just a few minutes ago and that specific error is gone but the issue of the plugin not working remains after doing what you suggested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests