polygon_map — a lightweight and easy-to-use package for working with map polygons. Create, edit, and display geometric areas with flexible customization.
Please star the repository to support the project!
To use this package, add it to your pubspec.yaml:
dependencies:
polygon_map: ^0.0.6or run the command
flutter pub add polygon_mapclass _MyAppState extends State<MyApp> {
final controller = PolygonMapController();
@override
void initState() {
super.initState();
controller.addListener(_onControllerChanged);
controller.setPolygons([
PolygonModel(
borderColor: Colors.red,
points: [
LatLng(34.0925, -118.2750),
LatLng(34.0925, -118.2050),
LatLng(34.0225, -118.1950),
LatLng(34.0125, -118.2050),
LatLng(34.0125, -118.2750),
],
),
]);
}
void _onControllerChanged() {
debugPrint("last polygon: ${controller.polygons.last.points}");
}
@override
void dispose() {
controller.removeListener(_onControllerChanged);
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: PolygonMap(
controller: controller,
mapType: MapTypeEnum.esriSatellite,
),
),
);
}
}



