我有一个列表,其中列出了分配给用户的所有任务,如下所示
public function index($data){
print_r($data);
}
点击每个任务都应打开一个详细信息页面。
@override
void initState() {
crudObj.getassignedData().then((results) {
setState(() {
Task = results;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: newdrawer(),
appBar: newappbar(),
body: _TaskList(),
floatingActionButton: FloatingActionButton(
foregroundColor: Colors.black54,
backgroundColor: Colors.blue,
elevation: 0,
child: Icon(Icons.add),
onPressed: () {
addDialog(context);
},
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
// ignore: non_constant_identifier_names
Widget _TaskList() {
if (Task != null) {
return ListView.builder(
itemCount: Task.documents.length,
padding: EdgeInsets.all(5.0),
itemBuilder: (context, i) {
return new ListTile(
title: Text(Task.documents[i].data['Title']),
subtitle: Text(Task.documents[i].data['Summary']),
onTap: (){
Navigator.push(context,
MaterialPageRoute(builder: (context)=>
taskdetail(Task.documents[i])
)
);
},
);
},
);
} else {
return Text('Loading, Please wait..');
}
}
}
我收到此错误:
class _taskdetailState extends State<taskdetail> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Details'),
),
body: ListView.builder(itemBuilder: (context,i)
{
return ListTile(
title: Text(widget.documents[i]['Title']),
);
}
),
);
}
}
答案 0 :(得分:1)
您可以尝试
title: Text("${Task.documents[i].data['Title']}"),
subtitle: Text("${Task.documents[i].data['Summary']}"),