Skip to content

Commit

Permalink
Fix return type num to double
Browse files Browse the repository at this point in the history
  • Loading branch information
JSUYA committed Jul 17, 2024
1 parent ba30459 commit 4f3195b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions packages/google_maps_flutter/lib/src/google_maps_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,10 @@ class GoogleMapsController {
'JSON.stringify(map.$method.apply(map, $args))');
}

Future<num> _getZoom(WebViewController controller) async {
Future<double> _getZoom(WebViewController controller) async {
try {
return await _callMethod(controller, 'getZoom', <String>[]) as num;
return (await _callMethod(controller, 'getZoom', <String>[]) as num) +
0.0;
} catch (e) {
debugPrint('JavaScript Error: $e');
return 0.0;
Expand Down Expand Up @@ -592,7 +593,7 @@ class GoogleMapsController {
JSON.stringify(getPixelToLatLng());
''';

return controller.runJavaScriptReturningResult(command) as String;
return await controller.runJavaScriptReturningResult(command) as String;
}

Future<String> _latLngToPoint(LatLng latLng) async {
Expand All @@ -612,11 +613,11 @@ class GoogleMapsController {
JSON.stringify(getLatLngToPixel());
''';

return controller.runJavaScriptReturningResult(command) as String;
return await controller.runJavaScriptReturningResult(command) as String;
}

/// Returns the zoom level of the current viewport.
Future<num> getZoomLevel() async {
Future<double> getZoomLevel() async {
return _getZoom(controller);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class GoogleMapsPlugin extends GoogleMapsFlutterPlatform {
Future<double> getZoomLevel({
required int mapId,
}) {
return _map(mapId).getZoomLevel() as Future<double>;
return _map(mapId).getZoomLevel();
}

// The following are the 11 possible streams of data from the native side
Expand Down

0 comments on commit 4f3195b

Please sign in to comment.