[英]type 'List<dynamic>' is not a subtype of type 'String'
[英]type 'String' is not a subtype of type 'int' of 'index'
var image; // this declaration I got wrong
String? category;
String? name;
DetailPage({Key? key, this.image, this.category, this.name}) : super(key: key);
AspectRatio(
aspectRatio: 3.5,
child: CarouselSlider(
items: widget.image['image'] // I want to display slider image on my product details page
.map<Widget>((item) => Padding(
padding: const EdgeInsets.only(left: 3, right: 3),
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(item),
fit: BoxFit.fitWidth)),
),
))
.toList(),
),
child: InkWell(
onTap: (){
Navigator.push(context, PageTransition(type: PageTransitionType.leftToRight,
child: DetailPage(
image:documentSnapshot['image'][0],
category:documentSnapshot['category'],
name:documentSnapshot['name'],
description:documentSnapshot['description'],
price:documentSnapshot['price'],
)));
},
您現在的寫法表明 image 是一張地圖,其中包含一個字段'image'
,它是某物的列表。 但錯誤表明image
本身已經是某物的列表,但不知道它是什么列表,很難說出它到底需要什么。 可能這已經有效
items: widget.image
.map<Widget>((item) => Padding(
padding: const EdgeInsets.only(left: 3, right: 3),
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(item),
fit: BoxFit.fitWidth)),
),
))
.toList(),
但這部分可能需要有所不同,具體取決於項目的外觀
image: NetworkImage(item),
也許它實際上是
image: NetworkImage(item['image']),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.