file<T extends Object> static method

Widget file<T extends Object>(
  1. String path, {
  2. Key? key,
  3. bool polygonCulling = false,
  4. PolygonProperties<T>? polygonProperties,
  5. Future<String> fileLoadBuilder(
    1. String
    )?,
  6. Polygon<T> builder(
    1. List<List<LatLng>> coordinates,
    2. Map<String, dynamic>? map
    )?,
  7. MapController? mapController,
  8. Widget fallback()?,
})

Loads and displays polygons from a file on a map.

The path parameter specifies the file path to the polygon data file.

Example:

PowerGeoJSONPolygons.file(
  'path/to/polygon_data.geojson',
  polygonProperties: PolygonProperties(
    strokeColor: Colors.green,
  ),
)

Implementation

static Widget file<T extends Object>(
  String path, {
  // layer
  Key? key,
  bool polygonCulling = false,
  PolygonProperties<T>? polygonProperties,
  Future<String> Function(String)? fileLoadBuilder,
  Polygon<T> Function(
    List<List<LatLng>> coordinates,
    Map<String, dynamic>? map,
  )?
  builder,
  MapController? mapController,
  Widget Function()? fallback,
}) {
  assert(
    (builder == null && polygonProperties != null) ||
        (polygonProperties == null && builder != null),
  );

  if (AppPlatform.isWeb) {
    throw UnsupportedError('Unsupported platform: Web');
  }
  return EnhancedFutureBuilder<Widget>(
    future: _filePolygons(
      fileLoadBuilder: fileLoadBuilder ?? defaultFileLoadBuilder,
      path,
      builder: builder,
      polygonProperties: polygonProperties,
      key: key,
      fallback: fallback,
      polygonCulling: polygonCulling,
      mapController: mapController,
    ),
    rememberFutureResult: true,
    whenDone: (Widget snapshotData) => snapshotData,
    whenNotDone: const Center(child: CupertinoActivityIndicator()),
  );
}