type 'List<String>' 不是 type 'String' 的子类型?
type 'List<String>' is not a subtype of type 'String'?
如何解决这个错误我无法解决还没有人帮助如何修复错误...................... ..................................................... ..................................................... ..................................................... .....................
home.dart
final List _bannerImage = [];
getBanner() {
_service.home.get().then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
setState(() {
_bannerImage.add(['image']);
});
});
});
}
Container(
height: 140,
width: MediaQuery.of(context).size.width,
color: Colors.grey,
child: PageView.builder(
itemCount: _bannerImage.length,
onPageChanged: (val) {
setState(() {
scrollPosition = val.toDouble();
});
},
itemBuilder: (BuildContext context, int index) {
return CachedNetworkImage(
imageUrl: _bannerImage[index],
fit: BoxFit.fill,
placeholder: (context, url) => GFShimmer(
showShimmerEffect: true,
mainColor: Colors.grey.shade500,
secondaryColor: Colors.grey.shade400,
child: Container(
height: 140,
child: const CircularProgressIndicator(),
width: MediaQuery.of(context).size.width,
color: Colors.grey,
),
),
);
// Image.network(
// _bannerImage[index],
// fit: BoxFit.cover,
// );
},
),
),
问题出在你添加列表而不是图像url
_bannerImage.add(['image']);
您需要像这样添加图片url
_bannerImage.add(doc['image']);
如何解决这个错误我无法解决还没有人帮助如何修复错误...................... ..................................................... ..................................................... ..................................................... .....................
home.dart
final List _bannerImage = [];
getBanner() {
_service.home.get().then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
setState(() {
_bannerImage.add(['image']);
});
});
});
}
Container(
height: 140,
width: MediaQuery.of(context).size.width,
color: Colors.grey,
child: PageView.builder(
itemCount: _bannerImage.length,
onPageChanged: (val) {
setState(() {
scrollPosition = val.toDouble();
});
},
itemBuilder: (BuildContext context, int index) {
return CachedNetworkImage(
imageUrl: _bannerImage[index],
fit: BoxFit.fill,
placeholder: (context, url) => GFShimmer(
showShimmerEffect: true,
mainColor: Colors.grey.shade500,
secondaryColor: Colors.grey.shade400,
child: Container(
height: 140,
child: const CircularProgressIndicator(),
width: MediaQuery.of(context).size.width,
color: Colors.grey,
),
),
);
// Image.network(
// _bannerImage[index],
// fit: BoxFit.cover,
// );
},
),
),
问题出在你添加列表而不是图像url
_bannerImage.add(['image']);
您需要像这样添加图片url
_bannerImage.add(doc['image']);