关于CachednetworkImage的Gradle构建错误-Flutter

问题描述 投票:0回答:1

运行Flutter应用程序时出现以下错误:

  Compiler message:
../../Documents/flutter/.pub-cache/hosted/pub.dartlang.org/cached_network_image-0.5.1/lib/cached_network_image.dart:199:38: 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' ('../../Documents/flutter/packages/flutter/lib/src/painting/image_stream.dart').
 - 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('../../Documents/flutter/packages/flutter/lib/src/painting/image_stream.dart').
Try changing the type of the parameter, or casting the argument to 'ImageStreamListener'.
      oldImageStream?.removeListener(_handleImageChanged);

有人可以建议出什么问题吗?

flutter android-gradle
1个回答
0
投票

只需在占位符之后添加((context,url)=>] >>] >>

new CachedNetworkImage(
              imageUrl: yourUrl,
              placeholder:(context, url) => new Image(
                image: AssetImage("assets/images/placeholder-image.png"),
                fit: BoxFit.cover,
              ),
            )

© www.soinside.com 2019 - 2024. All rights reserved.