问题描述
我试图构建一个应用程序,它向用户显示了Google地图上的某些地方。应用程序应从friestore获取的地点(位置,名称)数据。该应用程序已经可以在google地图中显示制造商,但是我还希望在Animated Builder中的应用程序底部显示一些详细信息,但它不起作用。问题是,我无法在specify['name']
函数中使用_restaurantList
来获取地点名称,但是在initMarker函数中却可以使用。我认为它必须做一些_restaurantList(specify)
和返回值_restaurantList(index)
的事情,但我不知道这是什么错误。我还尝试在_restaurantList(index)
中使用指定而不是索引,但是随后出现错误。但是我认为我必须先使用_restaurantList(specify)
才能在以后使用specify['name']
。
有人知道我的错误吗?
那是我的代码:
void initMarker(specify,specifyId) async {
// await Firebase.initializeApp();
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'),);
print(specify['location'].latitude);
nameTest = specify['name'];
setState(() {
markers[markerId] = marker;
print(markerId.toString() + '__________________________');
});
}
getMarkerData() async {
Firestore.instance.collection('seller').getDocuments().then((myMockDoc) {
if (myMockDoc.documents.isNotEmpty) {
for (int i = 0; i < myMockDoc.documents.length; i++) {
length = myMockDoc.documents.length;
print(length);
initMarker(
myMockDoc.documents[i].data(),myMockDoc.documents[i].documentID);
}
}
});
}
_restaurantList(specify) {
return AnimatedBuilder(
animation: _pageController,builder: (BuildContext context,Widget widget) {
double value = 1;
if (_pageController.position.haveDimensions) {
//value = _pageController.page - index;
value = (1 - (value.abs() * 0.3) + 0.06).clamp(0.0,1.0);
}
return Center(
child: SizedBox(
height: Curves.easeInOut.transform(value) * 175.0,width: Curves.easeInOut.transform(value) * 350.0,child: widget,),);
},child: InkWell(
onTap: () {
null;
},child: Stack(
children: [
Center(
child: Container(
margin: EdgeInsets.symmetric(
horizontal: 10.0,vertical: 20.0,height: 125.0,width: 275.0,decoration: Boxdecoration(
borderRadius: BorderRadius.circular(10.0),BoxShadow: [
BoxShadow(
color: Colors.black54,offset: Offset(0.0,4.0),blurRadius: 10.0,]),child: Container(
decoration: Boxdecoration(
borderRadius: BorderRadius.circular(10.0),color: Colors.white),child: Text(
specify['name'],)
],);
}
这是在脚手架中:
Positioned(
bottom: 20.0,child: Container(
height: 200.0,width: MediaQuery.of(context).size.width,child: PageView.builder(
controller: _pageController,itemCount: length,itemBuilder: (BuildContext context,int index) {
return _restaurantList(index);
},)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)