Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert non-p_i changes
  • Loading branch information
stuartmorgan-g committed Jul 22, 2022
commit 6b9a431db93562c78f9ce2e0b7b6a4c85d8d701a
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## 2.1.9
## NEXT

* Updates integration tests to use the new inspector interface.
* Removes obsolete test-only method for accessing a map controller's method channel.
* Ignores unnecessary import warnings in preparation for [upcoming Flutter changes](https://github.com/flutter/flutter/pull/106316).

## 2.1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,125 +2,87 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';

/// A method-channel-based implementation of [GoogleMapsInspectorPlatform], for
/// use in tests in conjunction with [MethodChannelGoogleMapsFlutter].
// TODO(stuartmorgan): Move this into the platform implementations when
// federating the mobile implementations.
class MethodChannelGoogleMapsInspector extends GoogleMapsInspectorPlatform {
/// Creates a method-channel-based inspector instance that gets the channel
/// for a given map ID from [mapsPlatform].
MethodChannelGoogleMapsInspector(MethodChannelGoogleMapsFlutter mapsPlatform)
: _mapsPlatform = mapsPlatform;

final MethodChannelGoogleMapsFlutter _mapsPlatform;

@override
Future<bool> areBuildingsEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isBuildingsEnabled'))!;
// TODO(a14n): remove this import once Flutter 3.1 or later reaches stable (including flutter/flutter#106316)
// ignore: unnecessary_import
import 'dart:typed_data';
import 'package:flutter/services.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

/// Inspect Google Maps state using the platform SDK.
///
/// This class is primarily used for testing. The methods on this
/// class should call "getters" on the GoogleMap object or equivalent
/// on the platform side.
class GoogleMapInspector {
GoogleMapInspector(this._channel);

final MethodChannel _channel;

Future<bool?> isCompassEnabled() async {
return await _channel.invokeMethod<bool>('map#isCompassEnabled');
}

@override
Future<bool> areRotateGesturesEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isRotateGesturesEnabled'))!;
Future<bool?> isMapToolbarEnabled() async {
return await _channel.invokeMethod<bool>('map#isMapToolbarEnabled');
}

@override
Future<bool> areScrollGesturesEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isScrollGesturesEnabled'))!;
Future<MinMaxZoomPreference> getMinMaxZoomLevels() async {
final List<double> zoomLevels =
(await _channel.invokeMethod<List<dynamic>>('map#getMinMaxZoomLevels'))!
.cast<double>();
return MinMaxZoomPreference(zoomLevels[0], zoomLevels[1]);
}

@override
Future<bool> areTiltGesturesEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isTiltGesturesEnabled'))!;
Future<double?> getZoomLevel() async {
final double? zoomLevel =
await _channel.invokeMethod<double>('map#getZoomLevel');
return zoomLevel;
}

@override
Future<bool> areZoomControlsEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isZoomControlsEnabled'))!;
Future<bool?> isZoomGesturesEnabled() async {
return await _channel.invokeMethod<bool>('map#isZoomGesturesEnabled');
}

@override
Future<bool> areZoomGesturesEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isZoomGesturesEnabled'))!;
Future<bool?> isZoomControlsEnabled() async {
return await _channel.invokeMethod<bool>('map#isZoomControlsEnabled');
}

@override
Future<MinMaxZoomPreference> getMinMaxZoomLevels({required int mapId}) async {
final List<double> zoomLevels = (await _mapsPlatform
.channel(mapId)
.invokeMethod<List<dynamic>>('map#getMinMaxZoomLevels'))!
.cast<double>();
return MinMaxZoomPreference(zoomLevels[0], zoomLevels[1]);
Future<bool?> isLiteModeEnabled() async {
return await _channel.invokeMethod<bool>('map#isLiteModeEnabled');
}

@override
Future<TileOverlay?> getTileOverlayInfo(TileOverlayId tileOverlayId,
{required int mapId}) async {
final Map<String, Object?>? tileInfo = await _mapsPlatform
.channel(mapId)
.invokeMapMethod<String, dynamic>(
'map#getTileOverlayInfo', <String, String>{
'tileOverlayId': tileOverlayId.value,
});
if (tileInfo == null) {
return null;
}
return TileOverlay(
tileOverlayId: tileOverlayId,
fadeIn: tileInfo['fadeIn']! as bool,
transparency: tileInfo['transparency']! as double,
visible: tileInfo['visible']! as bool,
// Android and iOS return different types.
zIndex: (tileInfo['zIndex']! as num).toInt(),
);
Future<bool?> isRotateGesturesEnabled() async {
return await _channel.invokeMethod<bool>('map#isRotateGesturesEnabled');
}

Future<bool?> isTiltGesturesEnabled() async {
return await _channel.invokeMethod<bool>('map#isTiltGesturesEnabled');
}

Future<bool?> isScrollGesturesEnabled() async {
return await _channel.invokeMethod<bool>('map#isScrollGesturesEnabled');
}

@override
Future<bool> isCompassEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isCompassEnabled'))!;
Future<bool?> isMyLocationButtonEnabled() async {
return await _channel.invokeMethod<bool>('map#isMyLocationButtonEnabled');
}

@override
Future<bool> isLiteModeEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isLiteModeEnabled'))!;
Future<bool?> isTrafficEnabled() async {
return await _channel.invokeMethod<bool>('map#isTrafficEnabled');
}

@override
Future<bool> isMapToolbarEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isMapToolbarEnabled'))!;
Future<bool?> isBuildingsEnabled() async {
return await _channel.invokeMethod<bool>('map#isBuildingsEnabled');
}

@override
Future<bool> isMyLocationButtonEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isMyLocationButtonEnabled'))!;
Future<Uint8List?> takeSnapshot() async {
return await _channel.invokeMethod<Uint8List>('map#takeSnapshot');
}

@override
Future<bool> isTrafficEnabled({required int mapId}) async {
return (await _mapsPlatform
.channel(mapId)
.invokeMethod<bool>('map#isTrafficEnabled'))!;
Future<Map<String, dynamic>?> getTileOverlayInfo(String id) async {
return await _channel.invokeMapMethod<String, dynamic>(
'map#getTileOverlayInfo', <String, String>{
'tileOverlayId': id,
});
}
}
Loading