Positioned(
bottom: 25,
right: 10,
child: FloatingActionButton(
heroTag: 'tag1',
backgroundColor: Colors.white.withOpacity(0.7),
child: Icon(
Icons.location_searching,
color: Colors.purple,
),
onPressed: () {
_addGeoPoint();
_animateToUser();
}),
),
Работает только _animateToUser
_animateToUser() async {
var pos = await location.getLocation();
mapController.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
target: LatLng(pos.latitude, pos.longitude), zoom: 17.0)));
}
_addGeoPoint не работает
Future<DocumentReference> _addGeoPoint() async {
var pos = await location.getLocation();
final coordinates = Coordinates(pos.latitude, pos.longitude);
var addresses =
await Geocoder.local.findAddressesFromCoordinates(coordinates);
var first = addresses.first;
print("${first.featureName} : ${first.addressLine}");
// GeoFirePoint point =
// geo.point(latitude: pos.latitude, longitude: pos.longitude);
return _firestore.collection('location').add({
'UserLocation': first.featureName,
'UserLocationName': first.addressLine
});
}
Но когда я изменился, нажмите
onPressed: _addGeopoint,
_addGeopoint работает.
Я не могу вызвать обе функции один раз.