vector_map 0.4.0 copy "vector_map: ^0.4.0" to clipboard
vector_map: ^0.4.0 copied to clipboard

outdated

Vector map for Flutter. Highly customizable. Compatible with GeoJSON. Map chart. Pure Flutter.

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:vector_map/vector_map.dart';

void main() {
  runApp(ExampleWidget());
}

class ExampleWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => ExampleState();
}

class ExampleState extends State<ExampleWidget> {
  MapDataSource? _dataSource;

  @override
  void initState() {
    super.initState();
    rootBundle.loadString('assets/south_america.json').then((geojson) {
      _loadDataSource(geojson);
    });
  }

  _loadDataSource(String geojson) async {
    MapDataSource dataSource = await MapDataSource.geoJSON(geojson: geojson);
    setState(() {
      _dataSource = dataSource;
    });
  }

  @override
  Widget build(BuildContext context) {
    Widget? content;
    if (_dataSource != null) {
      content = VectorMap(layers: [
        MapLayer(
            dataSource: _dataSource!,
            hoverTheme: MapTheme(color: Colors.green[900]))
      ]);
    } else {
      content = Text('Loading...');
    }

    return MaterialApp(
        debugShowCheckedModeBanner: false,
        theme: ThemeData(scaffoldBackgroundColor: Colors.white),
        home: Scaffold(
            body: Padding(child: content, padding: EdgeInsets.all(32))));
  }
}
76
likes
0
pub points
78%
popularity

Publisher

verified publishercaduandrade.net

Vector map for Flutter. Highly customizable. Compatible with GeoJSON. Map chart. Pure Flutter.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on vector_map