Showing
1 changed file
with
14 additions
and
19 deletions
... | @@ -39,6 +39,7 @@ class AddressSelectPageState extends State<AddressSelectPage> { | ... | @@ -39,6 +39,7 @@ class AddressSelectPageState extends State<AddressSelectPage> { |
39 | @override | 39 | @override |
40 | void initState() { | 40 | void initState() { |
41 | super.initState(); | 41 | super.initState(); |
42 | + _getCurrentLocation(); | ||
42 | } | 43 | } |
43 | 44 | ||
44 | Future<void> _getCurrentLocation() async { | 45 | Future<void> _getCurrentLocation() async { |
... | @@ -64,28 +65,22 @@ class AddressSelectPageState extends State<AddressSelectPage> { | ... | @@ -64,28 +65,22 @@ class AddressSelectPageState extends State<AddressSelectPage> { |
64 | _locationSubscription = | 65 | _locationSubscription = |
65 | location.onLocationChanged.listen((LocationData currentLocation) { | 66 | location.onLocationChanged.listen((LocationData currentLocation) { |
66 | _center = LatLng(currentLocation.latitude!, currentLocation.longitude!); | 67 | _center = LatLng(currentLocation.latitude!, currentLocation.longitude!); |
67 | - | ||
68 | - final String markerIdVal = 'marker_id_$_markerIdCounter'; | ||
69 | - _markerIdCounter++; | ||
70 | - final MarkerId markerId = MarkerId(markerIdVal); | ||
71 | - | ||
72 | - final Marker marker = Marker( | ||
73 | - markerId: markerId, | ||
74 | - position: LatLng(currentLocation.latitude!, currentLocation.longitude!), | ||
75 | - ); | ||
76 | - | ||
77 | - LatLng sydney = | ||
78 | - LatLng(currentLocation.latitude!, currentLocation.longitude!); | ||
79 | - mapController.moveCamera(CameraUpdate.newLatLng(sydney)); | ||
80 | - setState(() { | ||
81 | - markers[markerId] = marker; | ||
82 | - }); | ||
83 | }); | 68 | }); |
84 | } | 69 | } |
85 | 70 | ||
86 | void _onMapCreated(GoogleMapController controller) { | 71 | void _onMapCreated(GoogleMapController controller) { |
87 | mapController = controller; | 72 | mapController = controller; |
88 | - _getCurrentLocation(); | 73 | + final String markerIdVal = 'marker_id_$_markerIdCounter'; |
74 | + _markerIdCounter++; | ||
75 | + final MarkerId markerId = MarkerId(markerIdVal); | ||
76 | + final Marker marker = Marker( | ||
77 | + markerId: markerId, | ||
78 | + position: _center, | ||
79 | + ); | ||
80 | + mapController.moveCamera(CameraUpdate.newLatLng(_center)); | ||
81 | + setState(() { | ||
82 | + markers[markerId] = marker; | ||
83 | + }); | ||
89 | } | 84 | } |
90 | 85 | ||
91 | @override | 86 | @override |
... | @@ -121,7 +116,7 @@ class AddressSelectPageState extends State<AddressSelectPage> { | ... | @@ -121,7 +116,7 @@ class AddressSelectPageState extends State<AddressSelectPage> { |
121 | child: isLoading | 116 | child: isLoading |
122 | ? const GFLoader() | 117 | ? const GFLoader() |
123 | : ListView.separated( | 118 | : ListView.separated( |
124 | - controller: _controller, | 119 | + controller: _controller, |
125 | itemCount: 1, | 120 | itemCount: 1, |
126 | separatorBuilder: (_, index) => const Divider(), | 121 | separatorBuilder: (_, index) => const Divider(), |
127 | itemBuilder: (_, index) { | 122 | itemBuilder: (_, index) { |
... | @@ -133,7 +128,7 @@ class AddressSelectPageState extends State<AddressSelectPage> { | ... | @@ -133,7 +128,7 @@ class AddressSelectPageState extends State<AddressSelectPage> { |
133 | }, | 128 | }, |
134 | ); | 129 | ); |
135 | }, | 130 | }, |
136 | - ), | 131 | + ), |
137 | ), | 132 | ), |
138 | MyButton( | 133 | MyButton( |
139 | onPressed: () { | 134 | onPressed: () { | ... | ... |
-
Please register or login to post a comment