-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[google_maps_flutter]ChangeNotifier is replaced with granular callbacks #1302
Changes from 3 commits
6566963
cd47239
b55f004
e3c5cbf
f6fbbda
e488e75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,15 @@ part of google_maps_flutter; | |
|
|
||
| typedef void MapCreatedCallback(GoogleMapController controller); | ||
|
|
||
| /// Callback that receives updates to the camera position. | ||
| /// | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth adding "Used by: " and listing the relevant GoogleMap fields. |
||
| /// This callback is triggered when the platform google map | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Google Map |
||
| /// registers a camera movement. This will be called with null if | ||
| /// [GoogleMap.trackCameraPosition] is false. | ||
| /// | ||
| /// This is used in [GoogleMap.onCameraMove] and [GoogleMap.onMapOptionsUpdate]. | ||
| typedef void CameraPositionCallback(CameraPosition position); | ||
|
|
||
| class GoogleMap extends StatefulWidget { | ||
| const GoogleMap({ | ||
| @required this.initialCameraPosition, | ||
|
|
@@ -22,6 +31,9 @@ class GoogleMap extends StatefulWidget { | |
| this.trackCameraPosition = false, | ||
| this.myLocationEnabled = false, | ||
| this.markers, | ||
| this.onCameraMoveStarted, | ||
| this.onCameraMove, | ||
| this.onCameraIdle, | ||
| }) : assert(initialCameraPosition != null); | ||
|
|
||
| final MapCreatedCallback onMapCreated; | ||
|
|
@@ -58,9 +70,34 @@ class GoogleMap extends StatefulWidget { | |
| /// True if the map view should relay camera move events to Flutter. | ||
| final bool trackCameraPosition; | ||
|
|
||
| // Markers to be placed on the map. | ||
| /// Markers to be placed on the map. | ||
| final Set<Marker> markers; | ||
|
|
||
| /// Called when the camera starts moving. | ||
| /// | ||
| /// This can be initiated by the following: | ||
| /// 1. Non-gesture animation initiated in response to user actions. | ||
| /// For example: zoom buttons, my location button, or marker clicks. | ||
| /// 2. Developer initiated animation. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I'd call it "Programmatically initiated animation." |
||
| /// 3. Camera motion initiated in response to user gestures on the map. | ||
| /// For example: pan, tilt, pinch to zoom, or rotate. | ||
| /// | ||
| /// Note: This is callback is called even if trackCameraPosition is false. | ||
| final VoidCallback onCameraMoveStarted; | ||
|
|
||
| /// Called repeatedly as the camera continues to move after an | ||
| /// onCameraMoveStarted call. | ||
| /// | ||
| /// This may be called as often as once every frame and should | ||
| /// not perform expensive operations. | ||
| /// | ||
| /// This is callback is not called when trackCameraPosition is false. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. link trackCameraPosotion.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: since the default for trackCameraPosition is false, I'll reverse the negation (This is only called if [trackCameraPosition] is false). BTW does it never gets called if trackCameraPosition is false? in that case maybe it would make sense to get rid of trackCameraPosition and use the presence of this callback as the flag?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am pro getting rid of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM |
||
| final CameraPositionCallback onCameraMove; | ||
|
|
||
| /// Called when camera movement has ended, there are no pending | ||
| /// animations and the user has stopped interacting with the map. | ||
| final VoidCallback onCameraIdle; | ||
|
|
||
| /// True if a "My Location" layer should be shown on the map. | ||
| /// | ||
| /// This layer includes a location indicator at the current device location, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's nice to see!