alpha_world_map 0.1.0 copy "alpha_world_map: ^0.1.0" to clipboard
alpha_world_map: ^0.1.0 copied to clipboard

World map widget fetching live GeoJSON with full style customization

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 #

  1. Offline Caching

    Replace in-memory caches with persistent storage (e.g., Hive) to survive app restarts.

  2. Interactive Zones

    Wrap CustomPaint in a GestureDetector and use Path.contains() to detect taps on specific districts.

  3. Animation & Transitions

    Animate color changes or strokes by rebuilding with AnimatedBuilder.

  4. 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.

1
likes
130
points
15
downloads

Publisher

verified publisheralpha-kraft.blogspot.com

Weekly Downloads

World map widget fetching live GeoJSON with full style customization

Repository (GitHub)

Documentation

API reference

License

unknown (license)

Dependencies

flutter, geojson, http, svg_path_parser

More

Packages that depend on alpha_world_map