Package selection guidance compiled from public package information, community data, and project usage.
map_controller is a Flutter package designed to simplify the management of map elements such as markers, lines, and polygons. It provides a centralized controller to handle interactions, updates, and state changes for map content, improving code organization and performance. Ideal for applications requiring dynamic map visualization, it integrates seamlessly with Flutter's map widgets. The package is maintained by 'here' and available via pub.dev. Its source code is open on GitHub, enabling transparency and community contributions.
Use cases
Dynamic marker management
Real-time route visualization
Interactive polygon overlays
Map data synchronization
Location-based UI components
Key features
Centralized map state control
Support for markers, lines, and polygons
Efficient update mechanisms
Easy integration with Flutter maps
Open-source and actively maintained
Suitable for
Developers building interactive maps
Applications with real-time location tracking
Projects requiring complex map layering
Teams prioritizing clean, maintainable code
Flutter apps with geospatial data
Considerations
Requires compatible map widget implementation
Limited platform-specific customization
No built-in map rendering (depends on external map widget)
May need additional dependencies for advanced features
Documentation could be more detailed
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Map controller
Stateful map controller for Flutter Map. Manage markers, lines and polygons.
import'dart:async';
import'package:flutter/material.dart';
import'package:flutter_map/flutter_map.dart';
import'package:latlong/latlong.dart';
import'package:map_controller/map_controller.dart';
class_MapPageStateextendsState<MapPage> {
MapController mapController;
StatefulMapController statefulMapController;
StreamSubscription<StatefulMapControllerStateChange> sub;
@overridevoidinitState() {
// intialize the controllers
mapController = MapController();
statefulMapController = StatefulMapController(mapController: mapController);
// wait for the controller to be ready before using it
statefulMapController.onReady.then((_) => print("The map controller is ready")));
/// [Important] listen to the changefeed to rebuild the map on changes:/// this will rebuild the map when for example addMarker or any method /// that mutates the map assets is called
sub = statefulMapController.changeFeed.listen((change) => setState(() {}));
super.initState();
}
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
body: SafeArea(
child: Stack(children: <Widget>[
FlutterMap(
mapController: mapController,
options: MapOptions(center: LatLng(48.853831, 2.348722), zoom: 11.0),
layers: [
MarkerLayerOptions(markers: statefulMapController.markers),
PolylineLayerOptions(polylines: statefulMapController.lines),
PolygonLayerOptions(polygons: statefulMapController.polygons)
],
),
// ...
])),
);
}
@overridevoiddispose() {
sub.cancel();
super.dispose();
}
}
classMapPageextendsStatefulWidget{
@override_MapPageStatecreateState() => _MapPageState();
}