From f1e30f1a15624ec9b51d93d0298e67abe05110c7 Mon Sep 17 00:00:00 2001 From: Joey Boerwinkel Date: Tue, 11 Apr 2023 15:02:39 +0200 Subject: [PATCH] feat: add optional parameter for calling directions api --- lib/src/google_map.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/src/google_map.dart b/lib/src/google_map.dart index 76c9bd2..1f471e9 100644 --- a/lib/src/google_map.dart +++ b/lib/src/google_map.dart @@ -28,6 +28,7 @@ class GoogleTrackTraceMap extends StatefulWidget { this.buildingsEnabled = false, this.indoorViewEnabled = false, this.trafficEnabled = false, + this.retrieveDirections = true, this.mapStylingTheme, this.onTap, this.onArrived, @@ -62,6 +63,7 @@ class GoogleTrackTraceMap extends StatefulWidget { final bool tiltGesturesEnabled; final bool myLocationEnabled; final bool myLocationButtonEnabled; + final bool retrieveDirections; final bool zoomControlsEnabled; final bool zoomGesturesEnabled; final bool mapToolbarEnabled; @@ -169,9 +171,11 @@ class _GoogleTrackTraceMapState extends State { controller.mapController = ctr; if (widget.mapStylingTheme != null) { ctr.setMapStyle(widget.mapStylingTheme!.getJson()).onError( - (error, stackTrace) => - throw GoogleMapsException(error.toString()), - ); + (error, stackTrace) async { + print(error); + throw GoogleMapsException(error.toString()); + }, + ); } else { // No theme provided so switching to default ctr.setMapStyle( @@ -228,6 +232,9 @@ class _GoogleTrackTraceMapState extends State { } Future calculateRoute() async { + if (!widget.retrieveDirections) { + return; + } if (controller.route == null || checkTargetMoved()) { var directions = await DirectionsRepository() // TODO(freek): refactor this away