我是扑扑的初学者,我试图实现在轻按时获取任何项目的详细信息,我已经从firestore中获取了数据并使用ListView.Builder()建立了一个列表,现在我想显示在其他屏幕上按下的同一项目的详细信息。 我的listView.Builder是:
StreamBuilder(
stream: Firestore.instance.collection("TechnicalAnalysis").orderBy("TickerDateTime").snapshots(),
builder: (cotext, snapshot){
return ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) {
DocumentSnapshot ds = snapshot.data.documents[index];
return ListTile(
title: Text(
//"fdf",
//(ds["TickerTitle"]),
ds['TickerTitle'],
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
onTap: (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailScreen(
//check to add the db fields
obj1: (ds["TickerTitle"]+ds["TickerTitle"])
),
),
);
},
);
}
);
},
);
我的详细信息页面是
class DetailScreen extends StatelessWidget{
final GetAnalysis obj1;
const DetailScreen({Key key, this.obj1}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home:
Scaffold(
appBar: AppBar(
title:
Text("todo.title"),
),
body: Padding(
padding: EdgeInsets.all(16.0),
child:
Text(obj1.title),
),
)
);
}