@@ -15,15 +15,15 @@ import 'package:lost_found_steelhacks/utils.dart';
1515 * Displays the posted items on a Google map
1616 */
1717class MapPage extends StatefulWidget {
18- static BitmapDescriptor get lostMarkerIcon => BitmapDescriptor .defaultMarker;
19- static BitmapDescriptor get foundMarkerIcon => BitmapDescriptor .defaultMarker;
2018 const MapPage ({super .key});
2119
2220 @override
2321 State <MapPage > createState () => MapPageState ();
2422}
2523
2624class MapPageState extends State <MapPage > {
25+ BitmapDescriptor lostMarkerIcon = BitmapDescriptor .defaultMarker;
26+ BitmapDescriptor foundMarkerIcon = BitmapDescriptor .defaultMarker;
2727 late List <Item > currentLostItems;
2828 late List <Item > currentFoundItems;
2929 late GoogleMapController mapController;
@@ -36,21 +36,21 @@ class MapPageState extends State<MapPage> {
3636 currentLostItems = DataService .instance.lostItems;
3737 currentFoundItems = DataService .instance.foundItems;
3838
39- // BitmapDescriptor.fromAssetImage(
40- // const ImageConfiguration(size: Size(40, 40)),
41- // 'assets/location-pin.png')
42- // .then((icon) {
43- // setState(() {
44- // foundMarkerIcon = icon;
45- // });
46- // });
47- // BitmapDescriptor.fromAssetImage(
48- // const ImageConfiguration(size: Size(40, 40)), 'assets/lost-pin.png')
49- // .then((icon) {
50- // setState(() {
51- // lostMarkerIcon = icon;
52- // });
53- // });
39+ BitmapDescriptor .fromAssetImage (
40+ const ImageConfiguration (size: Size (40 , 40 )),
41+ 'assets/location-pin.png' )
42+ .then ((icon) {
43+ setState (() {
44+ foundMarkerIcon = icon;
45+ });
46+ });
47+ BitmapDescriptor .fromAssetImage (
48+ const ImageConfiguration (size: Size (40 , 40 )), 'assets/lost-pin.png' )
49+ .then ((icon) {
50+ setState (() {
51+ lostMarkerIcon = icon;
52+ });
53+ });
5454 }
5555
5656 void _onMapCreated (GoogleMapController controller) {
@@ -63,7 +63,7 @@ class MapPageState extends State<MapPage> {
6363
6464 // creating a new MARKER
6565 final Marker marker = Marker (
66- markerId: markerId, icon: MapPage . lostMarkerIcon, position: coords);
66+ markerId: markerId, icon: lostMarkerIcon, position: coords);
6767 counter++ ;
6868 setState (() {
6969 markers[markerId] = marker;
@@ -78,7 +78,7 @@ class MapPageState extends State<MapPage> {
7878 final MarkerId markerId = MarkerId (item.id);
7979 final Marker marker = Marker (
8080 markerId: markerId,
81- icon: lost ? MapPage . lostMarkerIcon : MapPage . foundMarkerIcon,
81+ icon: lost ? lostMarkerIcon : foundMarkerIcon,
8282 position: LatLng (geo.latitude, geo.longitude),
8383 onTap: () => routeSubpage (PostPage (item: item), context));
8484 markers[markerId] = marker;
0 commit comments