mapofchina 0.0.6 copy "mapofchina: ^0.0.6" to clipboard
mapofchina: ^0.0.6 copied to clipboard

A new Flutter package for china map.

绘制了一个中国地图,支持设置省份颜色,可以响应点击和缩放,以及提示。

Features #

image.png

Getting started #

dependencies:
  flutter:
    sdk: flutter

  mapofchina: ^0.0.4  
  

Usage #

import 'package:mapofchina/map/china_map.dart';
import 'package:mapofchina/map/data.dart';

class HomeWidget extends StatefulWidget {
  const HomeWidget({Key? key}) : super(key: key);

  @override
  State<HomeWidget> createState() => _HomeWidgetState();
}

class _HomeWidgetState extends State<HomeWidget> {
  @override
  void initState() {
    super.initState();
    //  OrientationPlugin.forceOrientation(DeviceOrientation.landscapeRight);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: MapWidget(
          //默认的提示语
          defaultToast: "北京 棒棒的",
          //可以自己编辑省份信息,也可以使用 generatedCityItemsHelper帮助类。
          cityItems: generatedCityItemsHelper((cityName) => CityItem(
                cityName: cityName,
                cityColor: _randomColor(),
                isSelected: cityName == ("山西") ? true : false,
              )),   
          //省份被点击的回调,传回去的String是用来更新提示语的。
          clickCallback: (cityName) {
            return "$cityName baby";
          },
          selectedStorkeColor: const Color(0xFF8BFDF0),
          background: const Color(0xFFF2F2F2),
        ),
      ),
    );
  }

  /// 随机生成颜色
  Color _randomColor() {
    var index = Random().nextInt(3) % 3;
    if (index == 0) return shallowColor;
    if (index == 1) return middleColor;
    if (index == 2) return depthColor;
    return middleColor;
  }
}

Additional information #

TODO: Tell users more about the package: where to find more information, how to contribute to the package, how to file issues, what response they can expect from the package authors, and more.

3
likes
85
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter package for china map.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on mapofchina