升级后 Flutter 不再工作

标签 flutter dart

我的项目运行完美,就在今天,我升级了我的 Flutter,然后一切都开始运行了。

底部是他们给我的错误。 请帮助我。

file:///Users/macbook/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/animated_background-1.0.4/lib/image_helper.dart:17:30: Error: The argument type 'dynamic Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
 - 'ImageInfo' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/macbook/Documents/flutter/packages/flutter/lib/src/painting/image_stream.dart').
 - 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/macbook/Documents/flutter/packages/flutter/lib/src/painting/image_stream.dart').
Try changing the type of the parameter, or casting the argument to 'ImageStreamListener'.
    newStream.removeListener(listener);
                             ^
file:///Users/macbook/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/animated_background-1.0.4/lib/image_helper.dart:20:25: Error: The argument type 'dynamic Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
 - 'ImageInfo' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/macbook/Documents/flutter/packages/flutter/lib/src/painting/image_stream.dart').
 - 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/macbook/Documents/flutter/packages/flutter/lib/src/painting/image_stream.dart').
Try changing the type of the parameter, or casting the argument to 'ImageStreamListener'.
  newStream.addListener(listener);
                        ^
file:///Users/macbook/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/animated_background-1.0.4/lib/image_helper.dart:21:41: Error: The argument type 'dynamic Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
 - 'ImageInfo' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/macbook/Documents/flutter/packages/flutter/lib/src/painting/image_stream.dart').
 - 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('file:///Users/macbook/Documents/flutter/packages/flutter/lib/src/painting/image_stream.dart').
Try changing the type of the parameter, or casting the argument to 'ImageStreamListener'.
  return () => newStream.removeListener(listener);
                                        ^
Compiler failed on /Users/macbook/AndroidStudioProjects/alimmentation/lib/main.dart
Finished with error: Gradle task assembleDebug failed with exit code 1

最佳答案

通过替换解决了类似的问题

/*...*/.addListener((ImageInfo image, bool synchronousCall) { /*...*/ });

import 'package:flutter/painting.dart';

/*...*/.addListener(new ImageStreamListener((ImageInfo image, bool synchronousCall) { /*...*/ }) as ImageStreamListener);

关于升级后 Flutter 不再工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56401223/

相关文章:

android - 捕获的图像小部件 : Failed assertion Flutter

visual-studio - sdk 中的 flutter_localizations 依赖于 intl 0.17.0,fstore 依赖于 intl ^0.16.1,禁止来自 sdk 的 flutter_localizations

flutter - Sizedbox 与填充列和行中的距离

dart - 如何选择要使用 flutter web 上传的文件和图像

flutter - 即使使用setState()后,返回到屏幕时ListView也不会重建吗?

android-studio - 没有 'Remove Widget' 选项用于在 Windows 10 中使用 Android Studio 进行抖动

dart - 在 dart web 项目中,输入和引用警告不应该是错误吗?

firebase - flutter 应用程序 - 使用谷歌分析数据 api 的趋势帖子

Flutter AnimatedSize 仅适用于一个方向

将 Provider 3 转换为 4 后 Flutter 应用程序崩溃