downloadOfflineRegion function
- OfflineRegionDefinition definition, {
- Map<
String, dynamic> metadata = const {}, - dynamic onEvent(
- DownloadRegionStatus event
Downloads the region described by definition for offline use and
completes with it once the region is created, before its tiles are in.
onEvent receives the progress of the download: InProgress events, then
Success, or Error with the PlatformException that stopped it. Its
code says why: see Error.
metadata is stored with the region as updateOfflineRegionMetadata
stores it, and fails the same way when it is not JSON-encodable.
Download events reach only the root isolate: in a background isolate,
passing onEvent throws an UnsupportedError. Leave it out there and
follow the download with getOfflineRegionStatus.
Throws a PlatformException with code INVALID_REGION_DEFINITION when
MapLibre cannot create a region from definition, such as one with a
mapStyleUrl without a scheme (assets/style.json), NaN bounds, or a
zoom range that is not finite, starts below 0 or is inverted.
Implementation
Future<OfflineRegion> downloadOfflineRegion(
OfflineRegionDefinition definition, {
Map<String, dynamic> metadata = const {},
Function(DownloadRegionStatus event)? onEvent,
}) => _global.downloadOfflineRegion(
definition,
metadata: metadata,
onEvent: onEvent == null ? null : (event) => onEvent(event),
);