Skip to content

Commit a6aef40

Browse files
authored
feat: improve string presentation for internal classes (#491)
1 parent 083fcc5 commit a6aef40

13 files changed

+375
-0
lines changed

lib/src/types/circles.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class Circle {
5252

5353
@override
5454
int get hashCode => Object.hash(circleId.hashCode, options.hashCode);
55+
56+
@override
57+
String toString() => 'Circle(circleId: $circleId, options: $options)';
5558
}
5659

5760
/// Defines CircleOptions for a circle.
@@ -157,6 +160,21 @@ class CircleOptions {
157160
visible.hashCode,
158161
zIndex.hashCode,
159162
);
163+
164+
@override
165+
String toString() =>
166+
'CircleOptions('
167+
'position: '
168+
'$position, '
169+
'radius: $radius, '
170+
'strokeWidth: $strokeWidth, '
171+
'strokeColor: $strokeColor, '
172+
'strokePattern: $strokePattern, '
173+
'fillColor: $fillColor, '
174+
'zIndex: $zIndex, '
175+
'visible: $visible, '
176+
'clickable: $clickable'
177+
')';
160178
}
161179

162180
/// Event emitted when a circle is clicked.
@@ -169,4 +187,7 @@ class CircleClickedEvent {
169187

170188
/// Id of the circle that has been tapped.
171189
final String circleId;
190+
191+
@override
192+
String toString() => 'CircleClickedEvent(circleId: $circleId)';
172193
}

lib/src/types/images.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,13 @@ class ImageDescriptor {
6565
width.hashCode,
6666
height.hashCode,
6767
);
68+
69+
@override
70+
String toString() =>
71+
'ImageDescriptor('
72+
'registeredImageId: $registeredImageId, '
73+
'imagePixelRatio: $imagePixelRatio, '
74+
'width: $width, '
75+
'height: $height'
76+
')';
6877
}

lib/src/types/lat_lng.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,7 @@ class LatLng {
7171

7272
@override
7373
int get hashCode => Object.hash(latitude.hashCode, longitude.hashCode);
74+
75+
@override
76+
String toString() => 'LatLng(latitude: $latitude, longitude: $longitude)';
7477
}

lib/src/types/lat_lng_bounds.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,8 @@ class LatLngBounds {
120120

121121
@override
122122
int get hashCode => Object.hash(southwest.hashCode, northeast.hashCode);
123+
124+
@override
125+
String toString() =>
126+
'LatLngBounds(southwest: $southwest, northeast: $northeast)';
123127
}

lib/src/types/markers.dart

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class Marker {
5050

5151
@override
5252
int get hashCode => Object.hash(markerId.hashCode, options.hashCode);
53+
54+
@override
55+
String toString() => 'Marker(markerId: $markerId, options: $options)';
5356
}
5457

5558
/// Defines MarkerOptions for a marker.
@@ -198,6 +201,22 @@ class MarkerOptions {
198201
visible.hashCode,
199202
zIndex.hashCode,
200203
);
204+
205+
@override
206+
String toString() =>
207+
'MarkerOptions('
208+
'alpha: $alpha, '
209+
'anchor: $anchor, '
210+
'draggable: $draggable, '
211+
'flat: $flat, '
212+
'icon: $icon, '
213+
'consumeTapEvents: $consumeTapEvents, '
214+
'position: $position, '
215+
'rotation: $rotation, '
216+
'infoWindow: $infoWindow, '
217+
'visible: $visible, '
218+
'zIndex: $zIndex'
219+
')';
201220
}
202221

203222
/// Text labels for [Marker] info window.
@@ -247,6 +266,10 @@ class InfoWindow {
247266
@override
248267
int get hashCode =>
249268
Object.hash(title.hashCode, snippet.hashCode, anchor.hashCode);
269+
270+
@override
271+
String toString() =>
272+
'InfoWindow(title: $title, snippet: $snippet, anchor: $anchor)';
250273
}
251274

252275
/// Specifies the anchor to be at a particular point in the marker image.
@@ -276,6 +299,9 @@ class MarkerAnchor {
276299

277300
@override
278301
int get hashCode => Object.hash(u.hashCode, v.hashCode);
302+
303+
@override
304+
String toString() => 'MarkerAnchor(u: $u, v: $v)';
279305
}
280306

281307
/// Marker event types
@@ -322,6 +348,10 @@ class MarkerEvent {
322348

323349
/// Type of the event.
324350
final MarkerEventType eventType;
351+
352+
@override
353+
String toString() =>
354+
'MarkerEvent(markerId: $markerId, eventType: $eventType)';
325355
}
326356

327357
/// Marker drag event sent from platform side.
@@ -344,4 +374,12 @@ class MarkerDragEvent {
344374

345375
/// Type of the event.
346376
final MarkerDragEventType eventType;
377+
378+
@override
379+
String toString() =>
380+
'MarkerDragEvent('
381+
'markerId: $markerId, '
382+
'eventType: $eventType, '
383+
'position: $position'
384+
')';
347385
}

lib/src/types/navigation_destinations.dart

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ class Destinations {
4242

4343
/// Navigation route token options.
4444
final RouteTokenOptions? routeTokenOptions;
45+
46+
@override
47+
String toString() =>
48+
'Destinations('
49+
'waypoints: $waypoints, '
50+
'displayOptions: $displayOptions, '
51+
'routingOptions: $routingOptions, '
52+
'routeTokenOptions: $routeTokenOptions'
53+
')';
4554
}
4655

4756
/// Provides options for routing using a route token
@@ -70,6 +79,10 @@ class RouteTokenOptions {
7079
/// If there is a mismatch, [travelMode] will override the travel mode used to
7180
/// generate the [routeToken].
7281
final NavigationTravelMode? travelMode;
82+
83+
@override
84+
String toString() =>
85+
'RouteTokenOptions(routeToken: $routeToken, travelMode: $travelMode)';
7386
}
7487

7588
/// Alternative routes strategy.
@@ -155,6 +168,19 @@ class RoutingOptions {
155168

156169
/// Maximum time to wait for a location fix before failure. (Only Android)
157170
final int? locationTimeoutMs;
171+
172+
@override
173+
String toString() =>
174+
'RoutingOptions('
175+
'alternateRoutesStrategy: $alternateRoutesStrategy, '
176+
'routingStrategy: $routingStrategy, '
177+
'targetDistanceMeters: $targetDistanceMeters, '
178+
'travelMode: $travelMode, '
179+
'avoidTolls: $avoidTolls, '
180+
'avoidFerries: $avoidFerries, '
181+
'avoidHighways: $avoidHighways, '
182+
'locationTimeoutMs: $locationTimeoutMs'
183+
')';
158184
}
159185

160186
/// Display options.
@@ -178,6 +204,14 @@ class NavigationDisplayOptions {
178204

179205
/// Show traffic lights.
180206
final bool? showTrafficLights;
207+
208+
@override
209+
String toString() =>
210+
'NavigationDisplayOptions('
211+
'showDestinationMarkers: $showDestinationMarkers, '
212+
'showStopSigns: $showStopSigns, '
213+
'showTrafficLights: $showTrafficLights'
214+
')';
181215
}
182216

183217
/// Navigation waypoint with different constructors based in on type of
@@ -248,6 +282,16 @@ class NavigationWaypoint {
248282
/// has a lane direction that aligns (within +/- 55 degrees) with the side of
249283
/// the road that the waypoint is on.
250284
int? preferredSegmentHeading;
285+
286+
@override
287+
String toString() =>
288+
'NavigationWaypoint('
289+
'title: $title, '
290+
'target: $target, '
291+
'placeID: $placeID, '
292+
'preferSameSideOfRoad: $preferSameSideOfRoad, '
293+
'preferredSegmentHeading: $preferredSegmentHeading'
294+
')';
251295
}
252296

253297
/// Status of the navigation routing.
@@ -310,6 +354,10 @@ class NavigationTimeAndDistance {
310354

311355
/// Distance to destination.
312356
final double distance;
357+
358+
@override
359+
String toString() =>
360+
'NavigationTimeAndDistance(time: $time, distance: $distance)';
313361
}
314362

315363
/// Navigation audio guidance type.
@@ -343,4 +391,12 @@ class NavigationAudioGuidanceSettings {
343391

344392
/// Guidance type.
345393
final NavigationAudioGuidanceType? guidanceType;
394+
395+
@override
396+
String toString() =>
397+
'NavigationAudioGuidanceSettings('
398+
'isBluetoothAudioEnabled: $isBluetoothAudioEnabled, '
399+
'isVibrationEnabled: $isVibrationEnabled, '
400+
'guidanceType: $guidanceType'
401+
')';
346402
}

lib/src/types/navigation_view_types.dart

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ class CameraPosition {
7575

7676
/// Zoom level near the center of the screen.
7777
final double zoom;
78+
79+
@override
80+
String toString() =>
81+
'CameraPosition('
82+
'bearing: $bearing, '
83+
'target: $target, '
84+
'tilt: $tilt, '
85+
'zoom: $zoom'
86+
')';
7887
}
7988

8089
/// Parameter given to parameter given to the [GoogleNavigationViewController.followMyLocation]
@@ -97,12 +106,19 @@ class CustomNavigationAutoEvent {
97106
final Object? data;
98107

99108
CustomNavigationAutoEvent({required this.event, required this.data});
109+
110+
@override
111+
String toString() => 'CustomNavigationAutoEvent(event: $event, data: $data)';
100112
}
101113

102114
class AutoScreenAvailabilityChangedEvent {
103115
final bool isAvailable;
104116

105117
AutoScreenAvailabilityChangedEvent({required this.isAvailable});
118+
119+
@override
120+
String toString() =>
121+
'AutoScreenAvailabilityChangedEvent(isAvailable: $isAvailable)';
106122
}
107123

108124
/// Represents the click position in a Google Maps view.
@@ -114,6 +130,9 @@ class MapClickEvent {
114130

115131
/// The location where the click happened.
116132
final LatLng target;
133+
134+
@override
135+
String toString() => 'MapClickEvent(target: $target)';
117136
}
118137

119138
/// Represents navigation UI changed event in a view.
@@ -124,6 +143,12 @@ class NavigationUIEnabledChangedEvent {
124143

125144
/// Value representing whether UI changed or not.
126145
final bool navigationUIEnabled;
146+
147+
@override
148+
String toString() =>
149+
'NavigationUIEnabledChangedEvent('
150+
'navigationUIEnabled: $navigationUIEnabled'
151+
')';
127152
}
128153

129154
/// Represents the long click position in a Google Maps view.
@@ -135,6 +160,9 @@ class MapLongClickEvent {
135160

136161
/// The location where the long click happened.
137162
final LatLng target;
163+
164+
@override
165+
String toString() => 'MapLongClickEvent(target: $target)';
138166
}
139167

140168
/// Traffic data statuses
@@ -165,6 +193,14 @@ class RouteSegmentTrafficDataRoadStretchRenderingData {
165193

166194
/// Offset in meters.
167195
final int offsetMeters;
196+
197+
@override
198+
String toString() =>
199+
'RouteSegmentTrafficDataRoadStretchRenderingData('
200+
'style: $style, '
201+
'lengthMeters: $lengthMeters, '
202+
'offsetMeters: $offsetMeters'
203+
')';
168204
}
169205

170206
/// Route segment traffic data road strech rendering style.
@@ -195,6 +231,13 @@ class RouteSegmentTrafficData {
195231
/// Rendering data list.
196232
final List<RouteSegmentTrafficDataRoadStretchRenderingData?>
197233
roadStretchRenderingDataList;
234+
235+
@override
236+
String toString() =>
237+
'RouteSegmentTrafficData('
238+
'status: $status, '
239+
'roadStretchRenderingDataList: $roadStretchRenderingDataList'
240+
')';
198241
}
199242

200243
/// Navigation route segment
@@ -220,6 +263,15 @@ class RouteSegment {
220263

221264
/// Destination waypoint.
222265
final NavigationWaypoint? destinationWaypoint;
266+
267+
@override
268+
String toString() =>
269+
'RouteSegment('
270+
'trafficData: $trafficData, '
271+
'destinationLatLng: $destinationLatLng, '
272+
'latLngs: $latLngs, '
273+
'destinationWaypoint: $destinationWaypoint'
274+
')';
223275
}
224276

225277
/// Internal camera update type.
@@ -396,6 +448,21 @@ class CameraUpdate {
396448

397449
/// The screen position co-ordinates for the zoom-by camera.
398450
Offset? focus;
451+
452+
@override
453+
String toString() =>
454+
'CameraUpdate('
455+
'type: $type, '
456+
'cameraPosition: $cameraPosition, '
457+
'latLng: $latLng, '
458+
'bounds: $bounds, '
459+
'padding: $padding, '
460+
'zoom: $zoom, '
461+
'zoomByAmount: $zoomByAmount, '
462+
'scrollByDx: $scrollByDx, '
463+
'scrollByDy: $scrollByDy, '
464+
'focus: $focus'
465+
')';
399466
}
400467

401468
/// My location clicked event.
@@ -444,4 +511,8 @@ class CameraChangedEvent {
444511

445512
/// Current position of the camera.
446513
final CameraPosition position;
514+
515+
@override
516+
String toString() =>
517+
'CameraChangedEvent(eventType: $eventType, position: $position)';
447518
}

0 commit comments

Comments
 (0)