Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[google_maps_flutter_platform_interface] Mark constructors as const for ids #3718

Merged
merged 3 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.2

* Mark constructors for CameraUpdate, CircleId, MapsObjectId, MarkerId, PolygonId, PolylineId and TileOverlayId as const

## 2.0.1

* Update platform_plugin_interface version requirement.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import 'dart:async';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/gestures.dart';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
import 'package:stream_transform/stream_transform.dart';

import '../types/tile_overlay_updates.dart';
import '../types/utils/tile_overlay.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class CameraPosition {
/// Defines a camera move, supporting absolute moves as well as moves relative
/// the current position.
class CameraUpdate {
CameraUpdate._(this._json);
const CameraUpdate._(this._json);

/// Returns a camera update that moves the camera to the specified position.
static CameraUpdate newCameraPosition(CameraPosition cameraPosition) {
Expand Down Expand Up @@ -176,15 +176,15 @@ class CameraUpdate {
///
/// Equivalent to the result of calling `zoomBy(1.0)`.
static CameraUpdate zoomIn() {
return CameraUpdate._(<Object>['zoomIn']);
return const CameraUpdate._(<Object>['zoomIn']);
}

/// Returns a camera update that zooms the camera out, bringing the camera
/// further away from the surface of the Earth.
///
/// Equivalent to the result of calling `zoomBy(-1.0)`.
static CameraUpdate zoomOut() {
return CameraUpdate._(<Object>['zoomOut']);
return const CameraUpdate._(<Object>['zoomOut']);
}

/// Returns a camera update that sets the camera zoom level.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'types.dart';
@immutable
class CircleId extends MapsObjectId<Circle> {
/// Creates an immutable identifier for a [Circle].
CircleId(String value) : super(value);
const CircleId(String value) : super(value);
}

/// Draws a circle on the map.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MapsObjectId<T> {
/// Creates an immutable object representing a [T] among [GoogleMap] Ts.
///
/// An [AssertionError] will be thrown if [value] is null.
MapsObjectId(this.value) : assert(value != null);
const MapsObjectId(this.value) : assert(value != null);

/// The value of the id.
final String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class InfoWindow {
@immutable
class MarkerId extends MapsObjectId<Marker> {
/// Creates an immutable identifier for a [Marker].
MarkerId(String value) : super(value);
const MarkerId(String value) : super(value);
}

/// Marks a geographical location on the map.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'types.dart';
@immutable
class PolygonId extends MapsObjectId<Polygon> {
/// Creates an immutable identifier for a [Polygon].
PolygonId(String value) : super(value);
const PolygonId(String value) : super(value);
}

/// Draws a polygon through geographical locations on the map.
Expand Down Expand Up @@ -167,7 +167,7 @@ class Polygon implements MapsObject {
fillColor == typedOther.fillColor &&
geodesic == typedOther.geodesic &&
listEquals(points, typedOther.points) &&
DeepCollectionEquality().equals(holes, typedOther.holes) &&
const DeepCollectionEquality().equals(holes, typedOther.holes) &&
visible == typedOther.visible &&
strokeColor == typedOther.strokeColor &&
strokeWidth == typedOther.strokeWidth &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PolylineId extends MapsObjectId<Polyline> {
/// Creates an immutable object representing a [PolylineId] among [GoogleMap] polylines.
///
/// An [AssertionError] will be thrown if [value] is null.
PolylineId(String value) : super(value);
const PolylineId(String value) : super(value);
}

/// Draws a line through geographical locations on the map.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
// found in the LICENSE file.

import 'dart:ui' show hashValues;

import 'package:flutter/foundation.dart';
import 'package:meta/meta.dart' show immutable;

import 'types.dart';
import 'package:meta/meta.dart' show immutable;

/// Uniquely identifies a [TileOverlay] among [GoogleMap] tile overlays.
@immutable
class TileOverlayId extends MapsObjectId<TileOverlay> {
/// Creates an immutable identifier for a [TileOverlay].
TileOverlayId(String value) : super(value);
const TileOverlayId(String value) : super(value);
}

/// A set of images which are displayed on top of the base map tiles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A common platform interface for the google_maps_flutter plugin.
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.0.1
version: 2.0.2

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';

import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();

test('toMap / fromMap', () {
final cameraPosition = CameraPosition(
const cameraPosition = CameraPosition(
target: LatLng(10.0, 15.0), bearing: 0.5, tilt: 30.0, zoom: 1.5);
// Cast to <dynamic, dynamic> to ensure that recreating from JSON, where
// type information will have likely been lost, still works.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();

test('keyByMapsObjectId', () async {
final MapsObjectId<TestMapsObject> id1 = MapsObjectId<TestMapsObject>('1');
final MapsObjectId<TestMapsObject> id2 = MapsObjectId<TestMapsObject>('2');
final MapsObjectId<TestMapsObject> id3 = MapsObjectId<TestMapsObject>('3');
final TestMapsObject object1 = TestMapsObject(id1);
final TestMapsObject object2 = TestMapsObject(id2, data: 2);
final TestMapsObject object3 = TestMapsObject(id3);
const MapsObjectId<TestMapsObject> id1 = MapsObjectId<TestMapsObject>('1');
const MapsObjectId<TestMapsObject> id2 = MapsObjectId<TestMapsObject>('2');
const MapsObjectId<TestMapsObject> id3 = MapsObjectId<TestMapsObject>('3');
const TestMapsObject object1 = TestMapsObject(id1);
const TestMapsObject object2 = TestMapsObject(id2, data: 2);
const TestMapsObject object3 = TestMapsObject(id3);
expect(
keyByMapsObjectId(<TestMapsObject>{object1, object2, object3}),
<MapsObjectId<TestMapsObject>, TestMapsObject>{
Expand All @@ -28,12 +28,12 @@ void main() {
});

test('serializeMapsObjectSet', () async {
final MapsObjectId<TestMapsObject> id1 = MapsObjectId<TestMapsObject>('1');
final MapsObjectId<TestMapsObject> id2 = MapsObjectId<TestMapsObject>('2');
final MapsObjectId<TestMapsObject> id3 = MapsObjectId<TestMapsObject>('3');
final TestMapsObject object1 = TestMapsObject(id1);
final TestMapsObject object2 = TestMapsObject(id2, data: 2);
final TestMapsObject object3 = TestMapsObject(id3);
const MapsObjectId<TestMapsObject> id1 = MapsObjectId<TestMapsObject>('1');
const MapsObjectId<TestMapsObject> id2 = MapsObjectId<TestMapsObject>('2');
const MapsObjectId<TestMapsObject> id3 = MapsObjectId<TestMapsObject>('3');
const TestMapsObject object1 = TestMapsObject(id1);
const TestMapsObject object2 = TestMapsObject(id2, data: 2);
const TestMapsObject object3 = TestMapsObject(id3);
expect(
serializeMapsObjectSet(<TestMapsObject>{object1, object2, object3}),
<Map<String, Object>>[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import 'dart:ui' show hashValues, hashList;

import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:google_maps_flutter_platform_interface/src/types/utils/maps_object.dart';
import 'package:google_maps_flutter_platform_interface/src/types/maps_object_updates.dart';
import 'package:google_maps_flutter_platform_interface/src/types/maps_object.dart';
import 'package:google_maps_flutter_platform_interface/src/types/maps_object_updates.dart';
import 'package:google_maps_flutter_platform_interface/src/types/utils/maps_object.dart';

import 'test_maps_object.dart';

Expand All @@ -23,15 +23,15 @@ void main() {

group('tile overlay updates tests', () {
test('Correctly set toRemove, toAdd and toChange', () async {
final TestMapsObject to1 =
const TestMapsObject to1 =
TestMapsObject(MapsObjectId<TestMapsObject>('id1'));
final TestMapsObject to2 =
const TestMapsObject to2 =
TestMapsObject(MapsObjectId<TestMapsObject>('id2'));
final TestMapsObject to3 =
const TestMapsObject to3 =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'));
final TestMapsObject to3Changed =
const TestMapsObject to3Changed =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'), data: 2);
final TestMapsObject to4 =
const TestMapsObject to4 =
TestMapsObject(MapsObjectId<TestMapsObject>('id4'));
final Set<TestMapsObject> previous =
Set.from(<TestMapsObject>[to1, to2, to3]);
Expand All @@ -40,8 +40,10 @@ void main() {
final TestMapsObjectUpdate updates =
TestMapsObjectUpdate.from(previous, current);

final Set<MapsObjectId<TestMapsObject>> toRemove = Set.from(
<MapsObjectId<TestMapsObject>>[MapsObjectId<TestMapsObject>('id1')]);
final Set<MapsObjectId<TestMapsObject>> toRemove =
Set.from(<MapsObjectId<TestMapsObject>>[
const MapsObjectId<TestMapsObject>('id1')
]);
expect(updates.objectIdsToRemove, toRemove);

final Set<TestMapsObject> toAdd = Set.from(<TestMapsObject>[to4]);
Expand All @@ -53,15 +55,15 @@ void main() {
});

test('toJson', () async {
final TestMapsObject to1 =
const TestMapsObject to1 =
TestMapsObject(MapsObjectId<TestMapsObject>('id1'));
final TestMapsObject to2 =
const TestMapsObject to2 =
TestMapsObject(MapsObjectId<TestMapsObject>('id2'));
final TestMapsObject to3 =
const TestMapsObject to3 =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'));
final TestMapsObject to3Changed =
const TestMapsObject to3Changed =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'), data: 2);
final TestMapsObject to4 =
const TestMapsObject to4 =
TestMapsObject(MapsObjectId<TestMapsObject>('id4'));
final Set<TestMapsObject> previous =
Set.from(<TestMapsObject>[to1, to2, to3]);
Expand All @@ -81,15 +83,15 @@ void main() {
});

test('equality', () async {
final TestMapsObject to1 =
const TestMapsObject to1 =
TestMapsObject(MapsObjectId<TestMapsObject>('id1'));
final TestMapsObject to2 =
const TestMapsObject to2 =
TestMapsObject(MapsObjectId<TestMapsObject>('id2'));
final TestMapsObject to3 =
const TestMapsObject to3 =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'));
final TestMapsObject to3Changed =
const TestMapsObject to3Changed =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'), data: 2);
final TestMapsObject to4 =
const TestMapsObject to4 =
TestMapsObject(MapsObjectId<TestMapsObject>('id4'));
final Set<TestMapsObject> previous =
Set.from(<TestMapsObject>[to1, to2, to3]);
Expand All @@ -109,15 +111,15 @@ void main() {
});

test('hashCode', () async {
final TestMapsObject to1 =
const TestMapsObject to1 =
TestMapsObject(MapsObjectId<TestMapsObject>('id1'));
final TestMapsObject to2 =
const TestMapsObject to2 =
TestMapsObject(MapsObjectId<TestMapsObject>('id2'));
final TestMapsObject to3 =
const TestMapsObject to3 =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'));
final TestMapsObject to3Changed =
const TestMapsObject to3Changed =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'), data: 2);
final TestMapsObject to4 =
const TestMapsObject to4 =
TestMapsObject(MapsObjectId<TestMapsObject>('id4'));
final Set<TestMapsObject> previous =
Set.from(<TestMapsObject>[to1, to2, to3]);
Expand All @@ -134,15 +136,15 @@ void main() {
});

test('toString', () async {
final TestMapsObject to1 =
const TestMapsObject to1 =
TestMapsObject(MapsObjectId<TestMapsObject>('id1'));
final TestMapsObject to2 =
const TestMapsObject to2 =
TestMapsObject(MapsObjectId<TestMapsObject>('id2'));
final TestMapsObject to3 =
const TestMapsObject to3 =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'));
final TestMapsObject to3Changed =
const TestMapsObject to3Changed =
TestMapsObject(MapsObjectId<TestMapsObject>('id3'), data: 2);
final TestMapsObject to4 =
const TestMapsObject to4 =
TestMapsObject(MapsObjectId<TestMapsObject>('id4'));
final Set<TestMapsObject> previous =
Set.from(<TestMapsObject>[to1, to2, to3]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
// found in the LICENSE file.

import 'dart:ui' show hashValues;

import 'package:flutter/rendering.dart';
import 'package:google_maps_flutter_platform_interface/src/types/maps_object_updates.dart';
import 'package:google_maps_flutter_platform_interface/src/types/maps_object.dart';
import 'package:google_maps_flutter_platform_interface/src/types/maps_object_updates.dart';

/// A trivial TestMapsObject implementation for testing updates with.
class TestMapsObject implements MapsObject {
TestMapsObject(this.mapsId, {this.data = 1});
const TestMapsObject(this.mapsId, {this.data = 1});

final MapsObjectId<TestMapsObject> mapsId;

Expand Down
Loading