【发布时间】:2020-11-07 16:25:09
【问题描述】:
我将 simple_slider 的依赖项添加到依赖项 (simple_slider: "^0.0.1") 下的 pubspec.yaml 文件中。我安装了它(应用程序运行没有错误)。但是当我添加以下代码时出现错误。
import 'package:flutter/material.dart';
import 'package:simple_slider/simple_slider.dart';
class HomeScreen extends StatelessWidget {
final _imageUrls = [
"assets/cus.png",
"assets/trans.png",
"assets/cus.png",
"assets/sea.jpg",
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Container(
child: ImageSliderWidget(
imageUrls: _imageUrls,
imageBorderRadius: BorderRadius.circular(10.0),
imageHeight: 8,
),
),
],
),
);
}
}
错误是,
Compiler message:
/C:/Users/B.R.P.Perera/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cached_network_image-0.4.2/lib/cached_network_image.dart:460:24: Error: The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
ImageStreamCompleter load(CachedNetworkImageProvider key) {
^
/D:/flutter/SDK/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
^
/C:/Users/B.R.P.Perera/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cached_network_image-0.4.2/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' ('/D:/flutter/SDK/flutter/packages/flutter/lib/src/painting/image_stream.dart').
- 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('/D:/flutter/SDK/flutter/packages/flutter/lib/src/painting/image_stream.dart').
oldImageStream?.removeListener(_handleImageChanged);
^
/C:/Users/B.R.P.Perera/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cached_network_image-0.4.2/lib/cached_network_image.dart:200:32: 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' ('/D:/flutter/SDK/flutter/packages/flutter/lib/src/painting/image_stream.dart').
- 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('/D:/flutter/SDK/flutter/packages/flutter/lib/src/painting/image_stream.dart').
_imageStream.addListener(_handleImageChanged);
^
/C:/Users/B.R.P.Perera/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cached_network_image-0.4.2/lib/cached_network_image.dart:210:34: 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' ('/D:/flutter/SDK/flutter/packages/flutter/lib/src/painting/image_stream.dart').
- 'ImageStreamListener' is from 'package:flutter/src/painting/image_stream.dart' ('/D:/flutter/SDK/flutter/packages/flutter/lib/src/painting/image_stream.dart').
_imageStream?.removeListener(_handleImageChanged);
^
/C:/Users/B.R.P.Perera/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cached_network_image-0.4.2/lib/cached_network_image.dart:464:31: Error: The argument type 'Null Function(StringBuffer)' can't be assigned to the parameter type 'Iterable<DiagnosticsNode> Function()'.
- 'StringBuffer' is from 'dart:core'.
- 'Iterable' is from 'dart:core'.
- 'DiagnosticsNode' is from 'package:flutter/src/foundation/diagnostics.dart' ('/D:/flutter/SDK/flutter/packages/flutter/lib/src/foundation/diagnostics.dart').
informationCollector: (StringBuffer information) {
^
我犯的错误在哪里? 谢谢。
【问题讨论】: