Skip to content

Commit

Permalink
chore: document MapPosition/PositionCallback.hasGesture in-code (#1973
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alestiago authored Oct 3, 2024
1 parent bf91ee0 commit d73d2f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/map/options/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ typedef PointerHoverCallback = void Function(
);

/// Callback that gets called when the viewport of the map changes.
///
/// {@macro map_position.has_gesture}
typedef PositionCallback = void Function(MapCamera camera, bool hasGesture);

/// All options for the [FlutterMap] widget.
Expand Down
12 changes: 12 additions & 0 deletions lib/src/misc/position.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ class MapPosition {
final LatLng? center;
final LatLngBounds? bounds;
final double? zoom;

/// {@template map_position.has_gesture}
/// [hasGesture] determines if the change was caused by a user gesture (interaction with the map) or not.
///
/// For example, if the user panned out the map, then [hasGesture] would be true because the change was
/// caused by a user gesture. On the other hand, if the map's position was changed using the map's
/// controller, then [hasGesture] would be false because the change was not caused by a user gesture,
/// but programmatically.
/// {@endtemplate}
final bool hasGesture;

const MapPosition({
Expand All @@ -29,4 +38,7 @@ class MapPosition {
other.zoom == zoom;
}

/// Callback that gets called when the map's position changes.
///
/// {@macro map_position.has_gesture}
typedef PositionCallback = void Function(MapPosition position, bool hasGesture);

0 comments on commit d73d2f1

Please sign in to comment.