Сообщение об ошибке, с которым я столкнулся, указывает на то, что метод currentLocation() определен для возврата Future, что означает, что он не возвращает никакого значения, и поэтому я не могу присвоить его результат в переменную.
Widget origin() {
return Positioned(
bottom: 20,
right: 15,
left: 15,
child: ElevatedButton(
onPressed: () async {
try {
// the error is on this line
GeoPoint currentLocation = await mapController.currentLocation();
debugPrint(
"Current Location: Latitude: ${currentLocation.latitude}, Longitude: ${currentLocation.longitude}");
await mapController.addMarker(
markerPosition: currentLocation,
markerIcon: MarkerIcon(
iconWidget: markerIcon,
),
);
setState(() {
geoPoint.add(currentLocation);
widgetStateList.add(destinationState);
});
} catch (e) {
debugPrint("Error getting current location: $e");
}
},
child: const Text(MyStrings.originSelect),
),
);
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... -cant-be-u
Я получил эту ошибку: «Это выражение имеет тип «void», поэтому его значение нельзя использовать» при попытке получить те ⇐ Android
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение