|
@@ -13,7 +13,8 @@ class AddLocationDataWidget extends StatefulWidget {
|
|
|
|
|
|
class _AddLocationDataWidgetState extends State<AddLocationDataWidget> {
|
|
class _AddLocationDataWidgetState extends State<AddLocationDataWidget> {
|
|
final MapController _mapController = MapController();
|
|
final MapController _mapController = MapController();
|
|
- ValueNotifier<LatLng?> selectedLocation = ValueNotifier(null);
|
|
|
|
|
|
+ LatLng? selectedLocation;
|
|
|
|
+ ValueNotifier hasSelectedLocation = ValueNotifier(false);
|
|
|
|
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
@@ -23,7 +24,6 @@ class _AddLocationDataWidgetState extends State<AddLocationDataWidget> {
|
|
@override
|
|
@override
|
|
void dispose() {
|
|
void dispose() {
|
|
super.dispose();
|
|
super.dispose();
|
|
- selectedLocation.dispose();
|
|
|
|
|
|
|
|
_mapController.dispose();
|
|
_mapController.dispose();
|
|
}
|
|
}
|
|
@@ -39,16 +39,17 @@ class _AddLocationDataWidgetState extends State<AddLocationDataWidget> {
|
|
maxZoom: 18.0,
|
|
maxZoom: 18.0,
|
|
minZoom: 2.8,
|
|
minZoom: 2.8,
|
|
onTap: (tapPosition, latlng) {
|
|
onTap: (tapPosition, latlng) {
|
|
- final zoom = selectedLocation.value == null
|
|
|
|
|
|
+ final zoom = selectedLocation == null
|
|
? _mapController.zoom + 2.0
|
|
? _mapController.zoom + 2.0
|
|
: _mapController.zoom;
|
|
: _mapController.zoom;
|
|
_mapController.move(latlng, zoom);
|
|
_mapController.move(latlng, zoom);
|
|
|
|
|
|
- selectedLocation.value = latlng;
|
|
|
|
|
|
+ selectedLocation = latlng;
|
|
|
|
+ hasSelectedLocation.value = true;
|
|
},
|
|
},
|
|
onPositionChanged: (position, hasGesture) {
|
|
onPositionChanged: (position, hasGesture) {
|
|
- if (selectedLocation.value != null) {
|
|
|
|
- selectedLocation.value = position.center;
|
|
|
|
|
|
+ if (selectedLocation != null) {
|
|
|
|
+ selectedLocation = position.center;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
),
|
|
),
|
|
@@ -63,6 +64,14 @@ class _AddLocationDataWidgetState extends State<AddLocationDataWidget> {
|
|
right: 10,
|
|
right: 10,
|
|
child: Column(
|
|
child: Column(
|
|
children: [
|
|
children: [
|
|
|
|
+ MapButton(
|
|
|
|
+ // icon: Icons.add_location_alt_outlined,
|
|
|
|
+ icon: Icons.check,
|
|
|
|
+
|
|
|
|
+ onPressed: () {},
|
|
|
|
+ heroTag: 'zoom-in',
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(height: 16),
|
|
MapButton(
|
|
MapButton(
|
|
icon: Icons.add,
|
|
icon: Icons.add,
|
|
onPressed: () {
|
|
onPressed: () {
|
|
@@ -87,39 +96,18 @@ class _AddLocationDataWidgetState extends State<AddLocationDataWidget> {
|
|
),
|
|
),
|
|
),
|
|
),
|
|
ValueListenableBuilder(
|
|
ValueListenableBuilder(
|
|
- valueListenable: selectedLocation,
|
|
|
|
|
|
+ valueListenable: hasSelectedLocation,
|
|
builder: (context, value, _) {
|
|
builder: (context, value, _) {
|
|
- return value != null
|
|
|
|
|
|
+ return value
|
|
? const Positioned(
|
|
? const Positioned(
|
|
- bottom: 20,
|
|
|
|
|
|
+ bottom: 16,
|
|
top: 0,
|
|
top: 0,
|
|
left: 0,
|
|
left: 0,
|
|
right: 0,
|
|
right: 0,
|
|
child: Icon(
|
|
child: Icon(
|
|
Icons.location_pin,
|
|
Icons.location_pin,
|
|
color: Color.fromARGB(255, 250, 34, 19),
|
|
color: Color.fromARGB(255, 250, 34, 19),
|
|
- size: 40,
|
|
|
|
- ),
|
|
|
|
- )
|
|
|
|
- : const SizedBox.shrink();
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- ValueListenableBuilder(
|
|
|
|
- valueListenable: selectedLocation,
|
|
|
|
- builder: (context, value, _) {
|
|
|
|
- return value != null
|
|
|
|
- ? Positioned(
|
|
|
|
- left: 0,
|
|
|
|
- right: 0,
|
|
|
|
- child: Row(
|
|
|
|
- children: [
|
|
|
|
- Text(
|
|
|
|
- selectedLocation.value.toString(),
|
|
|
|
- style: const TextStyle(
|
|
|
|
- color: Colors.black,
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
|
|
+ size: 32,
|
|
),
|
|
),
|
|
)
|
|
)
|
|
: const SizedBox.shrink();
|
|
: const SizedBox.shrink();
|