flutter_maps_package library

flutter_maps_package

A unified Flutter map package supporting both Google Maps and OpenStreetMap (OSM) with offline tile caching, region downloads, trail-based downloads, and administrative boundary scoping.

Getting Started

await FlutterMapsPackage.initialize(
  config: PackageConfig(
    googleMapsApiKey: 'YOUR_API_KEY',
    defaultProvider: MapProvider.osm,
  ),
);

Classes

AdminBoundaryService
Service for querying administrative boundary data.
AdminBoundaryStyle
Style configuration for administrative boundary overlays on the map.
AdminUnit
Represents a named administrative boundary unit (province, district, etc.).
BoundingBox
An axis-aligned geographic bounding box defined by two corners.
CacheStats
Statistics about the current state of the tile cache.
CameraPosition
Represents the camera's position over the map.
Coordinates
A geographic coordinate with latitude and longitude values.
CountryScope
Constrains map operations to a specific country and optional administrative levels within that country.
DirectionStep
A single navigation instruction step within a RouteSegment.
DownloadComplete
Emitted when a download completes successfully.
DownloadError
Emitted when a download fails.
DownloadEvent
Base class for events emitted during a tile region download.
DownloadProgress
Tracks the progress of an in-progress tile download.
DownloadTask
Represents an in-progress or cancellable tile download operation.
FlutterMapsPackage
The central entry-point for the flutter_maps_package.
MapController
Controls a mounted map widget: provider selection, camera movement, tile cache management, offline region downloads, and administrative scoping.
MapProviderAdapter
Adapter that each map provider (Google Maps, OSM, etc.) must implement to expose tile fetching, geocoding, and routing to the package internals.
MapWidget
The main map widget that renders a live OSM tile map with optional overlays and controls.
MapWidgetTheme
Visual theme configuration for the map widget's built-in controls.
OfflineRegion
Represents a downloaded offline map region.
PackageConfig
Top-level configuration for the flutter_maps_package.
Place
Represents a named geographic location returned by a search or geocoding operation.
PlacesService
High-level service for searching places across one or more map providers.
Route
A navigable route between two or more points, composed of RouteSegments.
RoutePolylineStyle
Style configuration for route polylines rendered on the map.
RouteSegment
A single segment of a Route, representing a polyline path with associated distance and duration.
RoutingService
High-level service for computing routes and turn-by-turn directions.
TileCache
A persistent, LRU-evicting on-disk tile cache.
TileCacheEntry
An entry in the tile cache index, representing metadata for a single cached tile.

Enums

AdminLevel
The administrative hierarchy level of an AdminUnit.
MapProvider
Enumerates the supported map providers.

Typedefs

CacheStaleCallback = void Function(TileKey tileKey, int ageSeconds)
Callback invoked by TileCache.get when a stale tile is served because the network refresh failed.
TileKey = ({int x, int y, int z})
A unique key identifying a map tile by its zoom level and tile coordinates.
Trail = List<Coordinates>
An ordered list of Coordinates representing a trail path.

Exceptions / Errors

FlutterMapsException
Base class for all exceptions thrown by the flutter_maps_package.
InitializationException
Thrown when the package fails to initialise correctly.
MapServiceException
Thrown when a map service (geocoding, routing, tile fetch, etc.) returns an error response.
NoRouteFoundException
Thrown when the routing service cannot find a valid route between two coordinates.
ScopeViolationException
Thrown when an operation would use a coordinate that lies outside the currently active bounding-box scope.