升级Flutter运行后,该应用程序无法运行。我升级是因为ImageStreamListener
我试图在不同的渠道[主,稳定,开发]上进行更改,但没有用。
我在Flutter中发现了this问题,但没有帮助。
这是我的flutter doctor
[✓] Flutter (Channel unknown, v1.7.11, on Mac OS X 10.14.5 18F132, locale en-PE)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.4)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.36.0)
[✓] Connected device (3 available)
错误消息
Compiler message:
file:///Users/enzoftware/Development/flutter/.pub-cache/hosted/pub.dartlang.org/palette_generator-0.1.1/lib/palette_generator.dart:188:29: Error: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
- 'ImageInfo' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/enzoftware/Development/flutter/packages/flutter/lib/src/painting/image_stream.dart').
- 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/enzoftware/Development/flutter/packages/flutter/lib/src/painting/image_stream.dart').
Try changing the type of the parameter, or casting the argument to 'ImageStreamListener'.
stream.removeListener(imageListener);
^
file:///Users/enzoftware/Development/flutter/.pub-cache/hosted/pub.dartlang.org/palette_generator-0.1.1/lib/palette_generator.dart:194:31: Error: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
- 'ImageInfo' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/enzoftware/Development/flutter/packages/flutter/lib/src/painting/image_stream.dart').
- 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/enzoftware/Development/flutter/packages/flutter/lib/src/painting/image_stream.dart').
Try changing the type of the parameter, or casting the argument to 'ImageStreamListener'.
stream.removeListener(imageListener);
^
file:///Users/enzoftware/Development/flutter/.pub-cache/hosted/pub.dartlang.org/palette_generator-0.1.1/lib/palette_generator.dart:201:24: Error: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
- 'ImageInfo' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/enzoftware/Development/flutter/packages/flutter/lib/src/painting/image_stream.dart').
- 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/enzoftware/Development/flutter/packages/flutter/lib/src/painting/image_stream.dart').
Try changing the type of the parameter, or casting the argument to 'ImageStreamListener'.
stream.addListener(imageListener);
^
Compiler failed on /Users/enzoftware/Projects/Wibo/wibo-flutter-mobile-user/lib/main.dart
FAILURE: Build failed with an exception.
* Where:
Script '/Users/enzoftware/Development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 652
* What went wrong:
Execution failed for task ':app:compileflutterBuildDebugArm'.
> Process 'command '/Users/enzoftware/Development/flutter/bin/flutter'' 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 29s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 29.7s
Gradle task assembleDebug failed with exit code 1
谢谢。
答案 0 :(得分:3)
我为此苦苦挣扎了几天,然后作为一个实验,从zoomable_image复制了源代码,并创建了本地文件zoomable.dart并编辑了令人反感的行:
_imageStream.addListener(_handleImageLoaded);
_imageStream.removeListener(_handleImageLoaded);
到
_imageStream.addListener(ImageStreamListener(_handleImageLoaded));
_imageStream.removeListener(ImageStreamListener(_handleImageLoaded));
我没有能力检出git文件并将其修复为git的新手。所有者不应该这样做吗?
答案 1 :(得分:1)
该API最近发生了重大变化。
这是旧用途与新用途的示例
// get the width, height
Image image = new Image.file(myImageFile);
Completer<ImageInfo> completer = Completer();
// Old API
// image.image
// .resolve(new ImageConfiguration())
// .addListener((ImageInfo info, bool _) {
// completer.complete(info);
// });
// New API
image.image
.resolve(new ImageConfiguration())
.addListener(ImageStreamListener((ImageInfo info, bool _) {
completer.complete(info);
}));
// wait for ImageInfo to finish
ImageInfo imageInfo = await completer.future;
答案 2 :(得分:0)
我从下面的链接获得了解决方案:
https://github.com/renefloor/flutter_cached_network_image/issues/197
this._networkImage.image.resolve(ImageConfiguration()).addListener(
ImageStreamListener((ImageInfo image, bool synchronousCall) {
if (mounted)
setState(() => this._imageDownloadState = ImageDownloadState.Done);
}));
谁在使用firebase_storage_image.dart文件,通常都会出现此问题。上面的代码将适用于此。
https://gist.github.com/jeroen-meijer/f0996dd35065c17ac79eeb3938bc89e4