我想列出一些不同的烤肉串商店。我创建了一个包含我需要的所有属性的列表,但flutter无法识别或显示该属性";name";或Listview生成器和中的任何其他属性
我不明白为什么我感谢每一个有用的命令。
错误:
没有为类型"List Doener"定义getter"image"。
并且这个Doenerscrollliste类在一个body容器中。
class DoenerScrollListe extends StatefulWidget {
const DoenerScrollListe({Key? key}) : super(key: key);
@override
State<DoenerScrollListe> createState() => _DoenerScrollListeState();
}
class _DoenerScrollListeState extends State<DoenerScrollListe> {
late PageController _pageController;
int initialPage = 1;
@override
void initState() {
super.initState();
_pageController = PageController();
}
@override
void dispose() {
super.dispose();
_pageController.dispose();
}
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: Doener_all.length,
scrollDirection: Axis.vertical,
addAutomaticKeepAlives: false,
shrinkWrap: true,
itemBuilder: (context, index) => Container(
height: 120,
width: double.infinity,
margin: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.orange[400],
image: DecorationImage(image: AssetImage(Doener_all.image))),
),
);
}
}
和我的模型文件
import 'package:flutter/material.dart';
class Doener {
final String name;
final String image;
final String ratingImage;
final String price;
final String describtion;
Doener({
required this.name,
required this.image,
required this.ratingImage,
required this.price,
required this.describtion,
});
}
// ignore: non_constant_identifier_names
List<Doener> Doener_all = [
Doener(
name: "Rüyam",
image: "assets/images/Ryam.jpg",
ratingImage: "dsd",
price: "4,10",
describtion: "Sehr guter Döner Top Preis Leistung"),
Doener(
name: "Pamfeliya",
image: "assets/images/Pamfilya.jpg",
ratingImage: "asdaa",
price: "4,10",
describtion: "Bestes Fleisch",
),
Doener(
name: "K'Ups",
image: "assets/images/KUps.jpg",
ratingImage: "sdsd",
price: "4,10",
describtion: "Guter Döner"),
];
在这种情况下,您希望获得特定的图像,更换
AssetImage(Doener_all.image)
带有
AssetImage(Doener_all[index].image))
关于List
的更多信息。