alpha_world_map
A Flutter package that fetches and renders both country (Admin 0) and subdivision (Admin 1) geometries at runtime, with full customization over fill and stroke colors for each layer. No static assets or preprocessing needed.
Features
- Fetches live GeoJSON data for countries and subdivisions.
- Customizable fill and stroke colors for country and district layers.
- Adjustable stroke width.
- Option to show or hide subdivisions.
- Caches data in memory to avoid refetching on rebuild.
Installation
Add the following to your pubspec.yaml:
dependencies:
flutter:
sdk: flutter
http: ^0.13.6
geojson: ^1.0.0
svg_path_parser: ^1.1.2
Then run:
flutter pub get
flutter pub get svg_path_parser: ^1.1.2
Usage
Import the package and use the AlphaWorldMap widget:
import 'package:flutter/material.dart';
import 'package:alpha_world_map/alpha_world_map.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp();
@override
Widget build(BuildContext ctx) => MaterialApp(home: const MapScreen());
}
class MapScreen extends StatelessWidget {
const MapScreen();
@override
Widget build(BuildContext ctx) {
return Scaffold(
appBar: AppBar(title: const Text('Customizable Alpha World Map')),
body: Center(
child: AlphaWorldMap(
countryCode: 'US',
countryFillColor: Colors.blue.shade200,
countryStrokeColor: Colors.blue.shade900,
districtFillColor: Colors.yellow.withOpacity(0.3),
districtStrokeColor: Colors.orange,
strokeWidth: 1.0,
showDistricts: true,
),
),
);
}
}
Data Sources and Coverage
- Country (Admin 0) geometries are fetched from Natural Earth GeoJSON repository.
- Subdivision (Admin 1) geometries are fetched from GADM static JSON files.
The package uses ISO-3166-1 alpha-2 country codes to fetch data. While these sources cover most countries, coverage of all 195 countries may vary depending on data availability. Please verify the country codes and data sources if you encounter missing countries.
Notes & Next Steps
-
Offline Caching
Replace in-memory caches with persistent storage (e.g., Hive) to survive app restarts.
-
Interactive Zones
Wrap
CustomPaintin aGestureDetectorand usePath.contains()to detect taps on specific districts. -
Animation & Transitions
Animate color changes or strokes by rebuilding with
AnimatedBuilder. -
Global View
For a full world view, fetch all Admin 0 geometries and draw them tiled or centered in a Mercator projection.
License
MIT License with Commercial Use Restriction. See LICENSE for details.
This package is made and maintained by Alpha Kraft.