1+ import 'package:flutter/animation.dart' ;
12import 'package:flutter_map/flutter_map.dart' ;
23import 'package:meta/meta.dart' ;
34
45/// All interactive options for [FlutterMap]
56@immutable
6- final class InteractionOptions {
7+ class InteractionOptions {
78 /// See [InteractiveFlag] for custom settings
89 final int flags;
910
@@ -66,6 +67,27 @@ final class InteractionOptions {
6667 /// with the scroll wheel of a mouse.
6768 final double scrollWheelVelocity;
6869
70+ /// Calculates the zoom difference to apply to the initial zoom level when a
71+ /// user is performing a double-tap drag zoom gesture
72+ ///
73+ /// `verticalOffset` is the vertical distance between the user's initial
74+ /// pointer-down position and their current dragged position. `camera` may be
75+ /// used, for example, to factor in the current zoom level.
76+ ///
77+ /// The default calculator is [defaultDoubleTapDragZoomChangeCalculator] .
78+ final double Function (double verticalOffset, MapCamera camera)
79+ doubleTapDragZoomChangeCalculator;
80+
81+ /// The duration of the animation played when double-tap zooming
82+ ///
83+ /// Defaults to 200ms.
84+ final Duration doubleTapZoomDuration;
85+
86+ /// The curve of the animation played when double-tap zooming
87+ ///
88+ /// Defaults to [Curves.fastOutSlowIn] .
89+ final Curve doubleTapZoomCurve;
90+
6991 /// Options to configure cursor/keyboard rotation
7092 ///
7193 /// Cursor/keyboard rotation is designed for desktop platforms, and allows the
@@ -103,21 +125,35 @@ final class InteractionOptions {
103125 this .pinchMoveWinGestures =
104126 MultiFingerGesture .pinchZoom | MultiFingerGesture .pinchMove,
105127 this .scrollWheelVelocity = 0.005 ,
128+ this .doubleTapDragZoomChangeCalculator =
129+ defaultDoubleTapDragZoomChangeCalculator,
130+ this .doubleTapZoomDuration = const Duration (milliseconds: 200 ),
131+ this .doubleTapZoomCurve = Curves .fastOutSlowIn,
106132 this .cursorKeyboardRotationOptions = const CursorKeyboardRotationOptions (),
107133 this .keyboardOptions = const KeyboardOptions (),
108134 }) : assert (
109135 rotationThreshold >= 0.0 ,
110- 'rotationThreshold needs to be a positive value ' ,
136+ '` rotationThreshold` must be positive' ,
111137 ),
112138 assert (
113139 pinchZoomThreshold >= 0.0 ,
114- 'pinchZoomThreshold needs to be a positive value ' ,
140+ '` pinchZoomThreshold` must be positive' ,
115141 ),
116142 assert (
117143 pinchMoveThreshold >= 0.0 ,
118- 'pinchMoveThreshold needs to be a positive value ' ,
144+ '` pinchMoveThreshold` must be positive' ,
119145 );
120146
147+ /// Default calculator function for [doubleTapDragZoomChangeCalculator]
148+ ///
149+ /// Uses a constant of 1/360, and changes the zoom speed based on the current
150+ /// zoom level.
151+ static double defaultDoubleTapDragZoomChangeCalculator (
152+ double verticalOffset,
153+ MapCamera camera,
154+ ) =>
155+ (1 / 360 ) * camera.zoom * verticalOffset;
156+
121157 @override
122158 bool operator == (Object other) =>
123159 other is InteractionOptions &&
@@ -131,6 +167,10 @@ final class InteractionOptions {
131167 pinchMoveThreshold == other.pinchMoveThreshold &&
132168 pinchMoveWinGestures == other.pinchMoveWinGestures &&
133169 scrollWheelVelocity == other.scrollWheelVelocity &&
170+ doubleTapDragZoomChangeCalculator ==
171+ other.doubleTapDragZoomChangeCalculator &&
172+ doubleTapZoomDuration == other.doubleTapZoomDuration &&
173+ doubleTapZoomCurve == other.doubleTapZoomCurve &&
134174 keyboardOptions == other.keyboardOptions;
135175
136176 @override
@@ -145,6 +185,9 @@ final class InteractionOptions {
145185 pinchMoveThreshold,
146186 pinchMoveWinGestures,
147187 scrollWheelVelocity,
188+ doubleTapDragZoomChangeCalculator,
189+ doubleTapZoomDuration,
190+ doubleTapZoomCurve,
148191 keyboardOptions,
149192 );
150193}
0 commit comments