Custom Marker in Flutter Getx or Normal in Statefull Widget

--

  Rx<BitmapDescriptor> markerIcon = BitmapDescriptor.defaultMarker.obs;  


void addCustomIcon() {
BitmapDescriptor.fromAssetImage(
const ImageConfiguration(), 'assets/svgs/logo.png')
.then(
(icon) {
markerIcon.value = icon;
},
);
}

Add marker in Marker List.

        markers.add(Marker(
markerId: const MarkerId('Target location'),
icon: markerIcon.value,
// icon:
// //markerbitmap,
// BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueRed),
draggable: true,
onDragEnd: (value) {
print("marker Dragble Value ===> $value");
// value is the new position
},
position: LatLng(lat!, long!),
infoWindow: const InfoWindow(title: "My Target Location")));

and call it first onReady or OnInit Function

  @override
void onReady() {
addCustomIcon();

// TODO: implement onReady
super.onReady();
}

--

--

Hasnain Mirrani
Hasnain Mirrani

Written by Hasnain Mirrani

Update the lattest and well explain All about Flutter make you from Zero to Hero in Flutter. follow Whatsapp :+923047040406, email: hmirrani@gmail.com https:/

No responses yet