Skip to content

Commit

Permalink
[Refactoring] Chanage the annotation from @required to required.
Browse files Browse the repository at this point in the history
  • Loading branch information
boris committed Jul 14, 2021
1 parent 96e7fce commit d6a8cf3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ class GoogleMapController {
final _GoogleMapState _googleMapState;

void _connectStreams(int mapId) {
_googleMapsFlutterPlatform
GoogleMapsFlutterPlatform.instance
.onMapReady(mapId: mapId)
.listen((_) {
_googleMapState.widget.onMapReady?.call();
_googleMapsFlutterPlatform.onMapReady(mapId: mapId).listen((_) => null);
GoogleMapsFlutterPlatform.instance.onMapReady(mapId: mapId).listen((_) => null);
});
if (_googleMapState.widget.onCameraMoveStarted != null) {
GoogleMapsFlutterPlatform.instance
Expand All @@ -79,7 +79,7 @@ class GoogleMapController {

GoogleMapsFlutterPlatform.instance
.onMarkerTap(mapId: mapId)
.listen((MarkerTapEvent e) => {
.listen((MarkerTapEvent e) {
_googleMapState.onMarkerTap(e.value);
_markerOnTapStreamController.add(e.value);
});
Expand Down Expand Up @@ -201,7 +201,7 @@ class GoogleMapController {
/// platform side.
Future<void> animateCamera(CameraUpdate cameraUpdate, {int animationSpeed = 2000, OnAnimationCompletedCallback? onAnimationCompletedCallback}) {
_onAnimationCompletedCallback = onAnimationCompletedCallback;
return _googleMapsFlutterPlatform.animateCamera(cameraUpdate, mapId: mapId, animationSpeed: animationSpeed);
return GoogleMapsFlutterPlatform.instance.animateCamera(cameraUpdate, mapId: mapId, animationSpeed: animationSpeed);
}

/// Changes the map camera position.
Expand Down Expand Up @@ -313,42 +313,42 @@ class GoogleMapController {
}

Future<void> updateNavigationIndex(int index, dynamic point) {
return _googleMapsFlutterPlatform.updateNavigationIndex(index, point, mapId: mapId);
return GoogleMapsFlutterPlatform.instance.updateNavigationIndex(index, point, mapId: mapId);
}

Future<void> initNavigationPolyline(List<dynamic> points, {Polyline skippedPolyline, Polyline remainingPolyline}) {
return _googleMapsFlutterPlatform.initNavigationPolyline(points, skippedPolyline: skippedPolyline, remainingPolyline: remainingPolyline, mapId: mapId);
Future<void> initNavigationPolyline(List<dynamic> points, {required Polyline skippedPolyline, required Polyline remainingPolyline}) {
return GoogleMapsFlutterPlatform.instance.initNavigationPolyline(points, skippedPolyline: skippedPolyline, remainingPolyline: remainingPolyline, mapId: mapId);
}

Future<void> initPolyline(Polyline polyline) {
return _googleMapsFlutterPlatform.initPolyline(polyline, mapId: mapId);
return GoogleMapsFlutterPlatform.instance.initPolyline(polyline, mapId: mapId);
}

Future<void> appendPolylinePoints(PolylineId polylineId, List<dynamic> points) {
return _googleMapsFlutterPlatform.appendPolylinePoints(polylineId, points, mapId: mapId);
return GoogleMapsFlutterPlatform.instance.appendPolylinePoints(polylineId, points, mapId: mapId);
}

Future<void> updateDynamicMarkers(Set<Marker> markers) {
return _googleMapsFlutterPlatform.updateDynamicMarkers(markers, mapId: mapId);
return GoogleMapsFlutterPlatform.instance.updateDynamicMarkers(markers, mapId: mapId);
}

Future<void> removeMarkers(Set<MarkerId> markerIds) {
return _googleMapsFlutterPlatform.vdRemoveMarkers(markerIds, mapId: mapId);
return GoogleMapsFlutterPlatform.instance.vdRemoveMarkers(markerIds, mapId: mapId);
}

Future<void> addSelfMarker(Marker marker) {
return _googleMapsFlutterPlatform.vdAddSelfMarker(marker, mapId: mapId);
return GoogleMapsFlutterPlatform.instance.vdAddSelfMarker(marker, mapId: mapId);
}

Future<void> updateSelfMarker(Marker marker) {
return _googleMapsFlutterPlatform.vdUpdateSelfMarker(marker, mapId: mapId);
return GoogleMapsFlutterPlatform.instance.vdUpdateSelfMarker(marker, mapId: mapId);
}

Future<void> cluster() {
return _googleMapsFlutterPlatform.cluster(mapId: mapId);
return GoogleMapsFlutterPlatform.instance.cluster(mapId: mapId);
}

Future<void> setClusterMarkerStyle(Color background, Color font) {
return _googleMapsFlutterPlatform.setClusterMarkerStyle(background, font, mapId: mapId);
return GoogleMapsFlutterPlatform.instance.setClusterMarkerStyle(background, font, mapId: mapId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class GoogleMap extends StatefulWidget {
required this.initialCameraPosition,
this.onMapCreated,
this.onMapReady,
this.gestureRecognizers = = const <Factory<OneSequenceGestureRecognizer>>{},
this.gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
this.compassEnabled = true,
this.mapToolbarEnabled = true,
this.cameraTargetBounds = CameraTargetBounds.unbounded,
Expand Down Expand Up @@ -86,7 +86,7 @@ class GoogleMap extends StatefulWidget {
/// Used to receive a [GoogleMapController] for this [GoogleMap].
final MapCreatedCallback? onMapCreated;

final VoidCallback onMapReady;
final VoidCallback? onMapReady;

/// The initial position of the map's camera.
final CameraPosition initialCameraPosition;
Expand Down Expand Up @@ -149,8 +149,6 @@ class GoogleMap extends StatefulWidget {
/// Tile overlays to be placed on the map.
final Set<TileOverlay> tileOverlays;

final VoidCallback? onMapReady;

/// Called when the camera starts moving.
///
/// This can be initiated by the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class TestGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform {
Future<void> animateCamera(
CameraUpdate cameraUpdate, {
required int mapId,
int animationSpeed = 2000,
}) async {}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
}

@override
Stream<MapReadyEvent> onMapReady({@required int mapId}) {
Stream<MapReadyEvent> onMapReady({required int mapId}) {
return _events(mapId).whereType<MapReadyEvent>();
}

Expand Down Expand Up @@ -609,15 +609,15 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
'$defaultTargetPlatform is not yet supported by the maps plugin');
}

Future<void> updateNavigationIndex(int index, dynamic point, { @required int mapId}) {
Future<void> updateNavigationIndex(int index, dynamic point, { required int mapId}) {
return channel(mapId).invokeMethod<void>('map#updateNavigationIndex', {
"index": index,
"point": point,
});
}

@override
Future<void> initNavigationPolyline(List<dynamic> points, {Polyline skippedPolyline, Polyline remainingPolyline, @required int mapId}) {
Future<void> initNavigationPolyline(List<dynamic> points, {required Polyline skippedPolyline, required Polyline remainingPolyline, required int mapId}) {
return channel(mapId).invokeMethod<void>('map#initNavigationPolyline', {
'points': points,
'skippedPolyline': skippedPolyline.toJson(),
Expand All @@ -626,47 +626,47 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
}

@override
Future<void> initPolyline(Polyline polyline, {@required int mapId}) {
Future<void> initPolyline(Polyline polyline, {required int mapId}) {
return channel(mapId).invokeMethod<void>('map#initPolyline', polyline.toJson());
}

@override
Future<void> appendPolylinePoints(PolylineId polylineId, List<dynamic> points, {@required int mapId}) {
Future<void> appendPolylinePoints(PolylineId polylineId, List<dynamic> points, {required int mapId}) {
return channel(mapId).invokeMethod<void>('map#appendPolylinePoints', {
'polylineId': polylineId.value,
"points": points,
});
}

Future<void> updateDynamicMarkers(Set<Marker> markers, {@required int mapId}) {
Future<void> updateDynamicMarkers(Set<Marker> markers, {required int mapId}) {
return channel(mapId).invokeMethod<void>('map#updateDynamicMarkers', {
'markers': serializeMarkerSet(markers),
});
}

Future<void> vdRemoveMarkers(Set<MarkerId> markerIds, {@required int mapId}) {
Future<void> vdRemoveMarkers(Set<MarkerId> markerIds, {required int mapId}) {
return channel(mapId).invokeMethod<void>('map#removeMarkers', {
'markerIds': markerIds.map<dynamic>((MarkerId m) => m.value).toList(),
});
}

Future<void> vdAddSelfMarker(Marker marker, {@required int mapId}) {
Future<void> vdAddSelfMarker(Marker marker, {required int mapId}) {
return channel(mapId).invokeMethod<void>('map#initMarker', {
'markers': serializeMarkerSet({marker}),
});
}

Future<void> vdUpdateSelfMarker(Marker marker, {@required int mapId}) {
Future<void> vdUpdateSelfMarker(Marker marker, {required int mapId}) {
return channel(mapId).invokeMethod<void>('map#updateMarker', {
'markers': serializeMarkerSet({marker}),
});
}

Future<void> cluster({@required int mapId}) {
Future<void> cluster({required int mapId}) {
return channel(mapId).invokeMethod<void>("map#cluster");
}

Future<void> setClusterMarkerStyle(Color background, Color font, {@required int mapId}) {
Future<void> setClusterMarkerStyle(Color background, Color font, {required int mapId}) {
return channel(mapId).invokeMethod<void>('map#setClusterMarkerStyle', {
'background': {
'a': background.alpha,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface {
Future<void> animateCamera(
CameraUpdate cameraUpdate, {
required int mapId,
int animationSpeed,
int animationSpeed = 2000,
}) {
throw UnimplementedError('animateCamera() has not been implemented.');
}
Expand Down Expand Up @@ -344,12 +344,12 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface {
}

/// when animate camera is completed
Stream<AnimateCameraCompletedEvent> animateCameraCompleted({@required int mapId}) {
Stream<AnimateCameraCompletedEvent> animateCameraCompleted({required int mapId}) {
throw UnimplementedError('animateCameraCompleted() has not been implemented.');
}

/// when map is ready
Stream<MapReadyEvent> onMapReady({@required int mapId}) {
Stream<MapReadyEvent> onMapReady({required int mapId}) {
throw UnimplementedError('onMapReady() has not been implemented.');
}

Expand All @@ -372,43 +372,43 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface {
throw UnimplementedError('buildView() has not been implemented.');
}

Future<void> updateNavigationIndex(int index, dynamic point, { @required int mapId}) {
Future<void> updateNavigationIndex(int index, dynamic point, { required int mapId}) {
throw UnimplementedError('initNavigationPolyline() has not been implemented.');
}

Future<void> initNavigationPolyline(List<dynamic> points, {Polyline skippedPolyline, Polyline remainingPolyline, @required int mapId}) {
Future<void> initNavigationPolyline(List<dynamic> points, {required Polyline skippedPolyline, required Polyline remainingPolyline, required int mapId}) {
throw UnimplementedError('initNavigationPolyline() has not been implemented.');
}

Future<void> initPolyline(Polyline polyline, {@required int mapId}) {
Future<void> initPolyline(Polyline polyline, {required int mapId}) {
throw UnimplementedError('initPolyline() has not been implemented.');
}

Future<void> appendPolylinePoints(PolylineId polylineId, List<dynamic> points, {@required int mapId}) {
Future<void> appendPolylinePoints(PolylineId polylineId, List<dynamic> points, {required int mapId}) {
throw UnimplementedError('addTrackingPoints() has not been implemented.');
}

Future<void> updateDynamicMarkers(Set<Marker> markers, {@required int mapId}) {
Future<void> updateDynamicMarkers(Set<Marker> markers, {required int mapId}) {
throw UnimplementedError('vdUpdateRiderMarkers() has not been implemented.');
}

Future<void> vdRemoveMarkers(Set<MarkerId> markerIds, {@required int mapId}) {
Future<void> vdRemoveMarkers(Set<MarkerId> markerIds, {required int mapId}) {
throw UnimplementedError('removeMarkers() has not been implemented.');
}

Future<void> vdAddSelfMarker(Marker marker, {@required int mapId}) {
Future<void> vdAddSelfMarker(Marker marker, {required int mapId}) {
throw UnimplementedError('vdAddSelfMarker() has not been implemented.');
}

Future<void> vdUpdateSelfMarker(Marker marker, {@required int mapId}) {
Future<void> vdUpdateSelfMarker(Marker marker, {required int mapId}) {
throw UnimplementedError('vdUpdateSelfMarker() has not been implemented.');
}

Future<void> cluster({@required int mapId}) {
Future<void> cluster({required int mapId}) {
throw UnimplementedError("cluster has not been implemented.");
}

Future<void> setClusterMarkerStyle(Color background, Color font, {@required int mapId}) {
Future<void> setClusterMarkerStyle(Color background, Color font, {required int mapId}) {
throw UnimplementedError("setClusterMarkerStyle has not been implemented.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class CameraUpdate {
]);
}

static CameraUpdate newLatLngBoundsWithEdgeInsets(LatLngBounds bounds, {double top, double left, double bottom, double right}) {
static CameraUpdate newLatLngBoundsWithEdgeInsets(LatLngBounds bounds, {double top = .0, double left = .0, double bottom = .0, double right = .0}) {
return CameraUpdate._(<dynamic>[
'newLatLngBoundsWithEdgeInsets',
bounds.toJson(),
Expand Down

0 comments on commit d6a8cf3

Please sign in to comment.