我正在从事一个颤动项目,我想弹出点击一个特定的瓷砖生成。这是我的代码
这是我的ListTile生成器
Future<Widget> getRecordView() {
print("405 name " + name.toString());
print(nameArr);
var items = List<Record>.generate(int.parse(widget.vcont), (index) => Record(
name: nameArr[index],
type: typeArr[index],
address: addressArr[index],
state: stateArr[index],
phone:phoneArr[index],
city: cityArr[index],
id: idArr[index],
));
print("Started");
var listItems = items;
var listview = ListView.builder(
itemCount: int.parse(widget.vcont),
itemBuilder: (context,index){
return listItems[index] ;
}
);
return Future.value(listview);
}
我需要的弹出窗口:
Future <bool> details(BuildContext context,String type) {
return Alert(
context: context,
type: AlertType.success,
title: "Submission",
desc: type, //The parameter
buttons: [
DialogButton(
child: Text(
"OKAY",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
color: Color.fromRGBO(0, 179, 134, 1.0),
radius: BorderRadius.circular(0.0),
),
],
).show();
}
我试图用GestureDetector和Inkwell来包装Record
,但是我只得到了错误,Android Studio告诉我在那个上下文中不应该使用Record
。我在网上查了查,找不到关于这件事的任何东西。请帮帮忙。
发布于 2021-07-10 15:36:48
记录,据我所知,这只是一个模型,而不是一个小部件。项目生成器需要小部件。您应该将传递给项构建器的内容与实际的小部件包装在一起,如容器()、ListTile()、..这些小部件可以用手势检测器包装,以执行您想要的弹出窗口。
它看起来就像这样
var listview = ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
// Tap on an item in the list and this will get executed.
},
// Return an actual widget, I'm using a ListTile here, but you can
// use any other type of widget here or a create custom widget.
child: ListTile(
// this will display the record names as list tiles.
title: Text(items[index].name),
),
);
},
);
https://stackoverflow.com/questions/68329036
复制相似问题