我有一个构建 GestureDetector 的 GridView.bulder,单击每个我用 [index] 导航详细信息。在每个 GestureDetector 中还有一个带有 GestureDetector 的列表,但是在这里我不明白如何打开绑定到原始 [index] 的特定数据文件,我试图在这样的列表中创建一个列表
class Brand {
final String image, title;
final int id;
final List <Subject> subjects;
Brand({
this.id,
this.image,
this.title,
this.subjects,
});
}
class Subject {
final int acura_id;
final String acura_image, acura_title;
Subject({
this.acura_id,
this.acura_image,
this.acura_title,
});
}
List<Brand> brands = [
Brand(
id: 1,
title: "ACURA",
image: "images/acura-logo.png",
subjects: [
Subject(
acura_id: 1,
acura_image: "images/acura/ilx.png",
acura_title: "ILX"
),
Subject(
acura_id: 2,
acura_image: "images/acura/rdx.png",
acura_title: "RDX"
),
],
),
];
但是当被调用时,它"${brand.subjects.acura_id}"会给出一个错误:getter 'acura_id' 没有为类型'List' 定义。(undefined_getter at [save_me] lib/cars_name.dart:43)
也许我用错了方式,如果你能帮助我理解为什么我不能调用列表或告诉我用哪种方式更改代码,我将不胜感激
应该给出 [index] 而不是 [0]