【发布时间】:2020-10-24 14:36:21
【问题描述】:
到目前为止,该应用可以做什么: 到目前为止,我有一个应用可以在 Google 地图上显示从 Firestore 获取坐标的标记。
我想要什么:我想要当用户按下标记时,他会来到另一个屏幕,在该屏幕上显示更多数据(数据也在 firestore 上)。
问题:我不知道如何获取要显示详细信息的屏幕上的数据(例如姓名)。
我有一个 onTap 函数,它调用goToDetailPage()
这就是 goToDetailPage() 函数:
void goToDetailPage() {
Navigator.of(context).push(new MaterialPageRoute(
builder: (BuildContext context) => new detailPage()));
}
这是“绘制”标记的代码:
void initMarker(specify, specifyId) async {
var markerIdVal = specifyId;
final MarkerId markerId = MarkerId(markerIdVal);
final Marker marker = Marker(
markerId: markerId,
position:
LatLng(specify['location'].latitude, specify['location'].longitude),
infoWindow: InfoWindow(title: specify['name'], snippet: 'Shop'),
onTap: () {
goToDetailPage();
});
print(specify['location'].latitude);
nameTest = specify['name'];
setState(() {
markers[markerId] = marker;
print(markerId.toString() + '__________________________');
});
}
这是详情页的代码:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Detail Page'),
),
body: Column(children: <Widget>[Text(specify['name'])]),
);
问题是详细页面中的指定['name']中的指定带有红色下划线,我不知道这是什么原因。
【问题讨论】:
标签: firebase flutter dart google-cloud-firestore android-context