Flutter_map: The method 'NetworkImageWithRetry.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'

Created on 12 Dec 2019  Â·  13Comments  Â·  Source: fleaflet/flutter_map

I've just upgraded to the latest Flutter 1.12 and running the example gives me this error:

Compiler message:
../../../../../bin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_image-2.0.0/lib/network.dart:73:24: Error: The method 'NetworkImageWithRetry.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
ImageStreamCompleter load(NetworkImageWithRetry key) {
^
../../../../../bin/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
^
../../../../../bin/flutter/.pub-cache/hosted/pub.dartlang.org/cached_network_image-1.1.3/lib/src/cached_network_image_provider.dart:42:24: Error: The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
ImageStreamCompleter load(CachedNetworkImageProvider key) {
^
../../../../../bin/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
^
../lib/src/layer/tile_provider/mbtiles_image_provider.dart:90:24: Error: The method 'MBTileImage.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
ImageStreamCompleter load(MBTileImage key) {
^
../../../../../bin/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed

Flutter doctor output:

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Linux, locale fr_FR.UTF-8)
• Flutter version 1.12.13+hotfix.5 at /home/me/bin/flutter
• Framework revision 27321ebbad (il y a 33 heures), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /home/me/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = /home/me/Android/Sdk
• Java binary at: /home/me/bin/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Android Studio (version 3.5)
• Android Studio at /home/me/bin/android-studio
• Flutter plugin version 41.1.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

This is due to the cached network image plugin: in this issue they recommend to upgrade to version cached_network_image: ^2.0.0-rc . I tried it but still get some errors. The only solution I found for now is to downgrade Flutter: flutter version v1.9.1+hotfix.6

Most helpful comment

  1. Upgrade flutter_image to 3.0.0
  2. 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,
    );
  }
  1. Go to mbtiles_image_provider.dart and again add DecoderCallback decode, as a second parameter in ImageProvider.load() function
  2. It should work for now.

All 13 comments

  1. Upgrade flutter_image to 3.0.0
  2. 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,
    );
  }
  1. Go to mbtiles_image_provider.dart and again add DecoderCallback decode, as a second parameter in ImageProvider.load() function
  2. It should work for now.

Thk bro ... i solved it

  1. Upgrade flutter_image to 3.0.0
  2. 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,
    );
  }
  1. Go to mbtiles_image_provider.dart and again add DecoderCallback decode, as a second parameter in ImageProvider.load() function
  2. It should work for now.

The following error occurs when updating. Or do I need to update not in my project?

Because flutter_map 0.7.3 depends on flutter_image ^2.0.0 and no versions of flutter_map match >0.7.3 <0.8.0, flutter_map ^0.7.3 requires flutter_image ^2.0.0.

So, because *** depends on both flutter_map ^0.7.3 and flutter_image ^3.0.0, version solving failed.
pub get failed (1; So, because *** depends on both flutter_map ^0.7.3 and flutter_image ^3.0.0, version solving failed.)

You have to update the original flutter_map pubspec.yaml file, not your project file.

Fixed in 0.8.0

Compiler message:
/C:/Flutter%20sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_image-1.0.0/lib/network.dart:72:24: Error: The method 'NetworkImageWithRetry.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
ImageStreamCompleter load(NetworkImageWithRetry key) {
^
/C:/Flutter%20sdk/flutter/packages/flutter/lib/src/painting/image_provider.dart:574:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
^
/C:/Flutter%20sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_image-1.0.0/lib/network.dart:75:31: Error: The argument type 'Null Function(StringBuffer)' can't be assigned to the parameter type 'Iterable Function()'.

  • 'StringBuffer' is from 'dart:core'.
  • 'Iterable' is from 'dart:core'.
  • 'DiagnosticsNode' is from 'package:flutter/src/foundation/diagnostics.dart' ('/C:/Flutter%20sdk/flutter/packages/flutter/lib/src/foundation/diagnostics.dart').
    informationCollector: (StringBuffer information) {
    ^
    /C:/Flutter%20sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_image-1.0.0/lib/network.dart:168:65: Error: The argument type 'String' can't be assigned to the parameter type 'DiagnosticsNode'.
  • 'DiagnosticsNode' is from 'package:flutter/src/foundation/diagnostics.dart' ('/C:/Flutter%20sdk/flutter/packages/flutter/lib/src/foundation/diagnostics.dart').
    context: '$runtimeType failed to load ${instructions.uri}',
    ^

Compiler message:
/C:/Flutter%20sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_image-1.0.0/lib/network.dart:72:24: Error: The method 'NetworkImageWithRetry.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
ImageStreamCompleter load(NetworkImageWithRetry key) {
^
/C:/Flutter%20sdk/flutter/packages/flutter/lib/src/painting/image_provider.dart:574:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
^
/C:/Flutter%20sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_image-1.0.0/lib/network.dart:75:31: Error: The argument type 'Null Function(StringBuffer)' can't be assigned to the parameter type 'Iterable Function()'.

  • 'StringBuffer' is from 'dart:core'.
  • 'Iterable' is from 'dart:core'.
  • 'DiagnosticsNode' is from 'package:flutter/src/foundation/diagnostics.dart' ('/C:/Flutter%20sdk/flutter/packages/flutter/lib/src/foundation/diagnostics.dart').
    informationCollector: (StringBuffer information) {
    ^
    /C:/Flutter%20sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_image-1.0.0/lib/network.dart:168:65: Error: The argument type 'String' can't be assigned to the parameter type 'DiagnosticsNode'.
  • 'DiagnosticsNode' is from 'package:flutter/src/foundation/diagnostics.dart' ('/C:/Flutter%20sdk/flutter/packages/flutter/lib/src/foundation/diagnostics.dart').
    context: '$runtimeType failed to load ${instructions.uri}',
    ^
    Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
    build failed.

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\Flutter sdk\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882

  • What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.

    Process 'command 'C:\Flutter sdk\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 30s
Exception: Gradle task assembleDebug failed with exit code 1

help me to solve this problem

I want to include a map in my application and this message occured when I run the app.

I have resolve the problem.

I have resolve the problem.

How did you resolve it ?

@DOUHADJI please honor the open community and disclose your solution, thx.

I get first these packages in my pubspecs.yaml file :
-flutter_map
-geoloction
-geolocator

And in my code i use this code :

`new FlutterMap(
mapController: controller,
options: new MapOptions(
minZoom: 17.0,
maxZoom: 100,
center: new LatLng( 6.136629, 1.222186),
),
layers: [
new TileLayerOptions(
urlTemplate: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",

                      subdomains: ['a' , 'b' , 'c']
                  ),
                  new MarkerLayerOptions(
                    markers: [
                      new Marker(
                          width: 40.0,
                          height: 40.0,
                          point:  new LatLng( 6.136629, 1.222186),
                        builder: (context) => new Container(
                          child: IconButton(
                            icon: Icon(Icons.location_on),
                            color: Colors.blue,
                            iconSize: 40.0,
                            onPressed: (){


                              showModalBottomSheet(
                                  context: context,
                                  builder:(builder){
                                    return Container(
                                      color: Colors.white,
                                      child: new Row(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        crossAxisAlignment: CrossAxisAlignment.center,
                                        children: <Widget>[
                                          Text('Votre position actuelle',
                                            style: TextStyle(
                                              color: Colors.black,
                                              fontSize: 15,
                                              fontWeight: FontWeight.w300,
                                            ) ,),
                                        ],
                                      ),
                                      height: MediaQuery.of(context).size.height/8,

                                    );
                              });
                            },
                          ),
                        )
                      )
                    ]
                  )
                ]
            ),`

In AndroidManifest (android/app/src/main/AndroidManifest.xml) do this:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanialV picture DanialV  Â·  6Comments

zozeei picture zozeei  Â·  4Comments

garrrettt picture garrrettt  Â·  4Comments

rktvsiim picture rktvsiim  Â·  5Comments

jacksos101 picture jacksos101  Â·  3Comments