Skip to content

Commit

Permalink
[BUG] Emit move event even when source is custom #1231 (#1232)
Browse files Browse the repository at this point in the history
* Emit a move event on zoom or center change when event source is custom #1231

* Remove unnecessary ? operator in example code found by dart analyze

Co-authored-by: Hagen Schendel <mail@hschendel.de>
  • Loading branch information
hschendel and Hagen Schendel authored May 12, 2022
1 parent bf782ba commit 0f1d5c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion example/lib/pages/tile_loading_error_handle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class _TileLoadingErrorHandleState extends State<TileLoadingErrorHandle> {
tileProvider: const NonCachingNetworkTileProvider(),
errorTileCallback: (Tile tile, error) {
if (_needLoadingError) {
WidgetsBinding.instance?.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
duration: const Duration(seconds: 1),
content: Text(
Expand Down
17 changes: 17 additions & 0 deletions lib/src/map/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,23 @@ class MapState {
source: source,
),
);
} else if (source == MapEventSource.custom) {
// for custom source, emit move event if zoom or center has changed
if (targetZoom != _zoom ||
_lastCenter == null ||
targetCenter.latitude != _lastCenter!.latitude ||
targetCenter.longitude != _lastCenter!.longitude) {
emitMapEvent(
MapEventMove(
id: id,
center: _lastCenter!,
zoom: _zoom,
targetCenter: targetCenter,
targetZoom: targetZoom,
source: source,
),
);
}
}
}

Expand Down

1 comment on commit 0f1d5c4

@ibrierley
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I seem to get a null error on WidgetsBinding.instance.addPostFrameCallback((), so wondering if it needs to be changed back to WidgetsBinding.instance?.addPostFrameCallback(() or WidgetsBinding.instance!.addPostFrameCallback((_) Not quite sure why it passed before, but does no one else get an error now ?

Please sign in to comment.