file static method

Widget file(
  1. String file, {
  2. required MarkerProperties markerProperties,
  3. MapController? mapController,
  4. Key? key,
  5. Future<String> fileLoadBuilder(
    1. String
    )?,
  6. Widget builder(
    1. BuildContext context,
    2. MarkerProperties markerProperties,
    3. Map<String, dynamic>? map
    )?,
  7. Widget fallback(
    1. int? statusCode
    )?,
  8. PowerMarkerClusterOptions? powerClusterOptions,
})

Creates a widget that displays a marker on a map using an image file located at the specified path.

The path parameter specifies the file path to the image that will be used as the marker icon.

The markerProperties parameter is required and contains properties for the marker, such as position and rotation.

The mapController parameter allows you to specify a custom MapController to control the map view. If not provided, the default MapController will be used.

The builder parameter is an optional callback function that allows you to customize the marker widget's appearance. It takes a BuildContext, MarkerProperties, and a map of extra data as arguments and should return a widget. If not provided, a default marker widget will be used.

The key parameter is an optional key that can be used to uniquely identify this widget.

Example usage:

file(
  '/path/to/marker.png',
  markerProperties: MarkerProperties(
    position: LatLng(37.7749, -122.4194),
    rotation: 45.0,
  ),
  mapController: myMapController,
  builder: (context, markerProperties, extraData) {
    return Icon(Icons.location_on, color: Colors.blue);
  },
)

In this example, the file widget will display a marker on the map using the image file located at '/path/to/marker.png', with custom properties, a custom builder function, and a specified map controller.

Returns a FutureBuilder widget that will build the marker widget once the file is loaded.

Implementation

static Widget file(
  String file, {
  required MarkerProperties markerProperties,
  MapController? mapController,
  Key? key,
  Future<String> Function(String)? fileLoadBuilder,
  Widget Function(
    BuildContext context,
    MarkerProperties markerProperties,
    Map<String, dynamic>? map,
  )?
  builder,
  Widget Function(int? statusCode)? fallback,
  PowerMarkerClusterOptions? powerClusterOptions,
}) {
  if (AppPlatform.isWeb) {
    throw UnsupportedError('Unsupported platform: Web');
  }
  return EnhancedFutureBuilder<Widget>(
    future: _fileMarkers(
      file,
      fileLoadBuilder: fileLoadBuilder ?? defaultFileLoadBuilder,
      powerClusterOptions: powerClusterOptions,
      markerLayerProperties: markerProperties,
      mapController: mapController,
      builder: builder,
      fallback: fallback,
      key: key,
    ),
    rememberFutureResult: true,
    whenDone: (Widget snapshotData) => snapshotData,
    whenNotDone: const Center(child: CupertinoActivityIndicator()),
  );
}