file<T extends Object> static method

Widget file<T extends Object>(
  1. String path, {
  2. required FeatureCollectionProperties<T> featureCollectionProperties,
  3. bool polygonCulling = false,
  4. MapController? mapController,
  5. Key? key,
  6. Future<String> fileLoadBuilder(
    1. String
    )?,
  7. required Widget builder(
    1. FeatureCollectionProperties<T> featureCollectionProperties,
    2. Map<String, dynamic>? map
    ),
  8. PowerMarkerClusterOptions? powerClusterOptions,
})

Loads and displays GeoJSON feature collections from a local file as a Widget.

  • path: The path to the local file containing the GeoJSON data.
  • featureCollectionProperties: Properties to customize the appearance of the feature collections.
  • polylineCulling: A boolean indicating whether polyline culling is enabled (default is false).
  • polygonCulling: A boolean indicating whether polygon culling is enabled (default is false).
  • mapController: An optional MapController for controlling the map view.
  • fileLoadBuilder: A function that reads the file and returns its content as a string.
  • builder: A function that takes the featureCollectionProperties and a map of feature properties and returns a Widget to render the features.
  • key: An optional Key for identifying the returned Widget.

Returns a Widget displaying the GeoJSON feature collections from the local file.

Implementation

static Widget file<T extends Object>(
  String path, {
  required FeatureCollectionProperties<T> featureCollectionProperties,
  bool polygonCulling = false,
  MapController? mapController,
  Key? key,
  Future<String> Function(String)? fileLoadBuilder,
  required Widget Function(
    FeatureCollectionProperties<T> featureCollectionProperties,
    Map<String, dynamic>? map,
  )
  builder,
  PowerMarkerClusterOptions? powerClusterOptions,
}) {
  if (AppPlatform.isWeb) {
    throw UnsupportedError('Unsupported platform: Web');
  }

  return EnhancedFutureBuilder<Widget>(
    future: _fileFeatureCollections(
      path,
      fileLoadBuilder: fileLoadBuilder ?? defaultFileLoadBuilder,
      powerClusterOptions: powerClusterOptions,
      featureCollectionLayerProperties: featureCollectionProperties,
      mapController: mapController,
      builder: builder,
      polygonCulling: polygonCulling,
      key: key,
    ),

    rememberFutureResult: true,
    whenDone: (Widget child) => child,
    whenNotDone: const Center(child: CupertinoActivityIndicator()),
  );
}