defaultMarkerBuilder static method

Widget defaultMarkerBuilder(
  1. BuildContext context,
  2. MarkerProperties markerProperties,
  3. Map<String, Object?>? properties, {
  4. Color? color,
})

Default marker builder function used to create markers for a map.

This function asynchronously loads an image asset, 'drop-pin.png', and creates a marker with the loaded image using the provided markerProperties for customization.

The context is required for building the widget tree, markerProperties defines the appearance of the marker, and properties is an optional map of additional properties associated with the marker.

If the image asset is successfully loaded, an Image widget displaying the image is returned. If the asset loading is still in progress, a CupertinoActivityIndicator is displayed as a loading indicator.

Example Usage:

Widget marker = _defaultMarkerBuilder(
  context,
  MarkerProperties(height: 48, width: 48),
  {'property1': 'value1', 'property2': 'value2'},
);

Returns a widget representing the marker.

Implementation

static Widget defaultMarkerBuilder(
  BuildContext context,
  MarkerProperties markerProperties,
  Map<String, Object?>? properties, {
  Color? color,
}) {
  return EnhancedFutureBuilder<List<int>>(
    future: _loadAssetImage(),
    rememberFutureResult: true,
    whenDone: (List<int> snapshotData) {
      Uint8List uint8list = Uint8List.fromList(snapshotData);
      return Image(
        image: MemoryImage(uint8list),
        color: color,
        height: markerProperties.height,
        width: markerProperties.width,
      );
    },
    whenNotDone: const Center(child: CupertinoActivityIndicator()),
  );
}