map: fixed address update on layer or orientation change
This commit is contained in:
parent
b720f65754
commit
c5942ba344
2 changed files with 18 additions and 7 deletions
|
@ -153,6 +153,8 @@ class _EntryLeafletMapState extends State<EntryLeafletMap> with TickerProviderSt
|
||||||
zoom: bounds.zoom,
|
zoom: bounds.zoom,
|
||||||
minZoom: widget.minZoom,
|
minZoom: widget.minZoom,
|
||||||
maxZoom: widget.maxZoom,
|
maxZoom: widget.maxZoom,
|
||||||
|
// TODO TLAD [map] as of flutter_map v0.14.0, `doubleTapZoom` does not move when zoom is already maximal
|
||||||
|
// this could be worked around with https://github.com/fleaflet/flutter_map/pull/960
|
||||||
interactiveFlags: interactive ? InteractiveFlag.all : InteractiveFlag.none,
|
interactiveFlags: interactive ? InteractiveFlag.all : InteractiveFlag.none,
|
||||||
onTap: (tapPosition, point) => widget.onMapTap?.call(),
|
onTap: (tapPosition, point) => widget.onMapTap?.call(),
|
||||||
controller: _leafletMapController,
|
controller: _leafletMapController,
|
||||||
|
|
|
@ -83,16 +83,17 @@ class _AddressRow extends StatefulWidget {
|
||||||
class _AddressRowState extends State<_AddressRow> {
|
class _AddressRowState extends State<_AddressRow> {
|
||||||
final ValueNotifier<String?> _addressLineNotifier = ValueNotifier(null);
|
final ValueNotifier<String?> _addressLineNotifier = ValueNotifier(null);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_updateAddress();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant _AddressRow oldWidget) {
|
void didUpdateWidget(covariant _AddressRow oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
final entry = widget.entry;
|
if (oldWidget.entry != widget.entry) {
|
||||||
if (oldWidget.entry != entry) {
|
_updateAddress();
|
||||||
_getAddressLine(entry).then((addressLine) {
|
|
||||||
if (mounted && entry == widget.entry) {
|
|
||||||
_addressLineNotifier.value = addressLine;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +137,14 @@ class _AddressRowState extends State<_AddressRow> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _updateAddress() async {
|
||||||
|
final entry = widget.entry;
|
||||||
|
final addressLine = await _getAddressLine(entry);
|
||||||
|
if (mounted && entry == widget.entry) {
|
||||||
|
_addressLineNotifier.value = addressLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<String?> _getAddressLine(AvesEntry? entry) async {
|
Future<String?> _getAddressLine(AvesEntry? entry) async {
|
||||||
if (entry != null && await availability.canLocatePlaces) {
|
if (entry != null && await availability.canLocatePlaces) {
|
||||||
final addresses = await GeocodingService.getAddress(entry.latLng!, entry.geocoderLocale);
|
final addresses = await GeocodingService.getAddress(entry.latLng!, entry.geocoderLocale);
|
||||||
|
|
Loading…
Reference in a new issue