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
create android settings class
  • Loading branch information
bparrishMines committed Aug 23, 2021
commit d90784525475b0f4fbcdb0bfbc4615ddc4b7eb3f
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ class MapsDemo extends StatelessWidget {

void main() {
if (defaultTargetPlatform == TargetPlatform.android) {
final MethodChannelGoogleMapsFlutter platform =
GoogleMapsFlutterPlatform.instance as MethodChannelGoogleMapsFlutter;
platform.useAndroidViewSurface = true;
AndroidGoogleMapsFlutter.useAndroidViewSurface = true;
}
runApp(MaterialApp(home: MapsDemo()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf
Cap,
Circle,
CircleId,
GoogleMapsFlutterPlatform,
InfoWindow,
JointType,
LatLng,
Expand All @@ -37,7 +36,6 @@ export 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf
MapType,
Marker,
MarkerId,
MethodChannelGoogleMapsFlutter,
MinMaxZoomPreference,
PatternItem,
Polygon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,48 @@ class UnknownMapObjectIdError extends Error {
}
}

/// Android specific settings for [GoogleMap].
class AndroidGoogleMapsFlutter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect this to be a MethodChannelGoogleMapsFlutter subclass. I guess we can add that later without it being a breaking change though, and doing it now would have registration complexities since we don't have dartPluginClass support for mobile on stable yet.

/// Whether to render [GoogleMap] with a [AndroidViewSurface] to build the Google Maps widget.
///
/// This implementation uses hybrid composition to render the Google Maps
/// Widget on Android. This comes at the cost of some performance on Android
/// versions below 10. See
/// https://flutter.dev/docs/development/platform-integration/platform-views#performance for more
/// information.
///
/// Defaults to false.
static bool get useAndroidViewSurface {
assert(
GoogleMapsFlutterPlatform.instance is MethodChannelGoogleMapsFlutter,
'This feature is only supported when `GoogleMapsFlutterPlatform.instance` '
'is a `MethodChannelGoogleMapsFlutter`. The default implementation for Android.',
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will interfere with people setting mock platform implementations for tests, which is the recommended way of mocking federated plugins. We should no-op it (returning false) rather than asserting.

return (GoogleMapsFlutterPlatform.instance
as MethodChannelGoogleMapsFlutter)
.useAndroidViewSurface;
}

/// Set whether to render [GoogleMap] with a [AndroidViewSurface] to build the Google Maps widget.
///
/// This implementation uses hybrid composition to render the Google Maps
/// Widget on Android. This comes at the cost of some performance on Android
/// versions below 10. See
/// https://flutter.dev/docs/development/platform-integration/platform-views#performance for more
/// information.
///
/// Defaults to false.
static set useAndroidViewSurface(bool useAndroidViewSurface) {
assert(
GoogleMapsFlutterPlatform.instance is MethodChannelGoogleMapsFlutter,
'This feature is only supported when `GoogleMapsFlutterPlatform.instance` '
'is a `MethodChannelGoogleMapsFlutter`. The default implementation for Android.',
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

(GoogleMapsFlutterPlatform.instance as MethodChannelGoogleMapsFlutter)
.useAndroidViewSurface = useAndroidViewSurface;
}
}

/// A widget which displays a map with data obtained from the Google Maps service.
class GoogleMap extends StatefulWidget {
/// Creates a widget displaying data from Google Maps services.
Expand Down