What I'm trying to do is that when I tap a list tile, it generates new marker on its location(based on latitude and longitude) on the map.
but the variables do not update and only show initial value which is 0. If I remove 0 and start hot reload, they print out as null.
class UpdatedStoresListState extends State<UpdatedStoresList> {
double updatedLat = 0;
double updatedLon = 0;
@override
void initState() {
super.initState();
}
it generates new latitude and longitude when I tap ListTile widget.
class UpdatedStoresListState extends State<UpdatedStoresList> {
...
children: <Widget>[
GestureDetector(
onTap: () {
setState(() {
updatedLat = snapshot.data[index].latitude;
updatedLon = snapshot.data[index].longitude;
print('Lat: $updatedLat');
// 52.902...
print('Lon: $updatedLon');
// -129.9031...
});
},
child: ListTile(
I need to use new values for 'Marker' widget. It is in another statefulwidget in different .dart file.
class _MainMapState extends State<MainMap> {
...
Marker(
width: 40.0,
height: 40.0,
point: LatLng(UpdatedStoresListState().updatedLat, UpdatedStoresListState().updatedLon),
builder: (ctx) => Container(
child: FlutterLogo(),
),
)
I really appreciate any help you can provide