mapchart 0.6.0+1 copy "mapchart: ^0.6.0+1" to clipboard
mapchart: ^0.6.0+1 copied to clipboard

discontinuedreplaced by: vector_map

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

example/lib/main.dart

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

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

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

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

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

  _loadDataSource(String geojson) async {
    MapChartDataSource dataSource = await MapChartDataSource.geoJSON(
        geojson: geojson, keys: ['GEOCODIGO'], parseToNumber: ['GEOCODIGO']);
    setState(() {
      _dataSource = dataSource;
    });
  }

  @override
  Widget build(BuildContext context) {
    Widget? content;
    if (_dataSource != null) {
      content = _buildMapChart();
    } else {
      content = Text('Loading...');
    }

    MultiSplitView multiSplitView =
        MultiSplitView(children: [content, Container(width: 50)]);

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(scaffoldBackgroundColor: Colors.white),
      home: Scaffold(
          body: Center(
              child: SizedBox(width: 600, height: 500, child: multiSplitView))),
    );
  }

  Widget _buildMapChart() {
    return MapChart(
        dataSource: _dataSource,
        theme: MapChartTheme.gradient(
            contourColor: Colors.green[800],
            key: 'GEOCODIGO',
            colors: [Colors.yellow, Colors.lightGreen]),
        hoverTheme: MapChartTheme(color: Colors.green[900]));
  }
}
5
likes
110
pub points
0%
popularity

Publisher

verified publishercaduandrade.net

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on mapchart