Skip to content
Closed
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
1 change: 1 addition & 0 deletions example/lib/generated_plugin_registrant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// ignore_for_file: directives_ordering
// ignore_for_file: lines_longer_than_80_chars
// ignore_for_file: depend_on_referenced_packages

import 'package:device_info_plus_web/device_info_plus_web.dart';
import 'package:location_web/location_web.dart';
Expand Down
20 changes: 0 additions & 20 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:location/location.dart';
Expand All @@ -13,7 +11,6 @@ import 'package:mapbox_gl_example/offline_regions.dart';
import 'package:mapbox_gl_example/place_batch.dart';
import 'package:mapbox_gl_example/layer.dart';
import 'package:mapbox_gl_example/sources.dart';
import 'package:device_info_plus/device_info_plus.dart';

import 'animate_camera.dart';
import 'annotation_order_maps.dart';
Expand All @@ -29,7 +26,6 @@ import 'place_source.dart';
import 'place_symbol.dart';
import 'place_fill.dart';
import 'scrolling_map.dart';
import 'package:mapbox_gl/mapbox_gl.dart';

final List<ExamplePage> _allPages = <ExamplePage>[
MapUiPage(),
Expand Down Expand Up @@ -72,22 +68,6 @@ class _MapsDemoState extends State<MapsDemo> {
super.initState();
}

/// Determine the android version of the phone and turn off HybridComposition
/// on older sdk versions to improve performance for these
///
/// !!! Hybrid composition is currently broken do no use !!!
Future<void> initHybridComposition() async {
if (!kIsWeb && Platform.isAndroid) {
final androidInfo = await DeviceInfoPlugin().androidInfo;
final sdkVersion = androidInfo.version.sdkInt;
if (sdkVersion != null && sdkVersion >= 29) {
MapboxMap.useHybridComposition = true;
} else {
MapboxMap.useHybridComposition = false;
}
}
}

void _pushPage(BuildContext context, ExamplePage page) async {
if (!kIsWeb) {
final location = Location();
Expand Down
3 changes: 3 additions & 0 deletions example/lib/map_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ class MapUiBodyState extends State<MapUiBody> {
myLocationEnabled: _myLocationEnabled,
myLocationTrackingMode: _myLocationTrackingMode,
myLocationRenderMode: MyLocationRenderMode.GPS,
onStyleLoadedCallback: () async {
print("onStyleLoadedCallback");
},
onMapClick: (point, latLng) async {
print(
"Map click: ${point.x},${point.y} ${latLng.latitude}/${latLng.longitude}");
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: 'none'
version: 1.0.0+1

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.17.0-0 <3.0.0'

dependencies:
flutter:
Expand Down
9 changes: 5 additions & 4 deletions lib/src/mapbox_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ class MapboxMap extends StatefulWidget {
/// Set `MapboxMap.useHybridComposition` to `false` in order use Virtual-Display
/// (better for Android 9 and below but may result in errors on Android 12)
/// or leave it `true` (default) to use Hybrid composition (Slower on Android 9 and below).
static bool get useHybridComposition =>
MethodChannelMapboxGl.useHybridComposition;
static set useHybridComposition(bool useHybridComposition) =>
MethodChannelMapboxGl.useHybridComposition = useHybridComposition;
/// Depreacted with Flutter 3 support
@Deprecated("No longer necessary with Flutter 3")
static bool get useHybridComposition => false;
@Deprecated("No longer necessary with Flutter 3")
static set useHybridComposition(bool useHybridComposition) => {};

@override
State createState() => _MapboxMapState();
Expand Down
78 changes: 33 additions & 45 deletions mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ part of mapbox_gl_platform_interface;

class MethodChannelMapboxGl extends MapboxGlPlatform {
late MethodChannel _channel;
static bool useHybridComposition = false;

Future<dynamic> _handleMethodCall(MethodCall call) async {
switch (call.method) {
Expand Down Expand Up @@ -141,50 +140,39 @@ class MethodChannelMapboxGl extends MapboxGlPlatform {
OnPlatformViewCreatedCallback onPlatformViewCreated,
Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers) {
if (defaultTargetPlatform == TargetPlatform.android) {
if (useHybridComposition) {
return PlatformViewLink(
viewType: 'plugins.flutter.io/mapbox_gl',
surfaceFactory: (
BuildContext context,
PlatformViewController controller,
) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
gestureRecognizers: gestureRecognizers ??
const <Factory<OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
);
},
onCreatePlatformView: (PlatformViewCreationParams params) {
final SurfaceAndroidViewController controller =
PlatformViewsService.initSurfaceAndroidView(
id: params.id,
viewType: 'plugins.flutter.io/mapbox_gl',
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
onFocus: () => params.onFocusChanged(true),
);
controller.addOnPlatformViewCreatedListener(
params.onPlatformViewCreated,
);
controller.addOnPlatformViewCreatedListener(
onPlatformViewCreated,
);

controller.create();
return controller;
},
);
} else {
return AndroidView(
viewType: 'plugins.flutter.io/mapbox_gl',
onPlatformViewCreated: onPlatformViewCreated,
gestureRecognizers: gestureRecognizers,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
);
}
return PlatformViewLink(
viewType: 'plugins.flutter.io/mapbox_gl',
surfaceFactory: (
BuildContext context,
PlatformViewController controller,
) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
gestureRecognizers: gestureRecognizers ??
const <Factory<OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
);
},
onCreatePlatformView: (PlatformViewCreationParams params) {
final ExpensiveAndroidViewController controller =
PlatformViewsService.initExpensiveAndroidView(
id: params.id,
viewType: 'plugins.flutter.io/mapbox_gl',
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
onFocus: () => params.onFocusChanged(true),
);
controller.addOnPlatformViewCreatedListener(
params.onPlatformViewCreated,
);
controller.addOnPlatformViewCreatedListener(
onPlatformViewCreated,
);

return controller;
},
);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
return UiKitView(
viewType: 'plugins.flutter.io/mapbox_gl',
Expand Down
4 changes: 2 additions & 2 deletions mapbox_gl_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ dependencies:
meta: ^1.0.5

environment:
sdk: '>=2.12.0 <3.0.0'
flutter: ">=2.0.0"
sdk: '>=2.17.0 <3.0.0'
flutter: ">=3.0.0"
4 changes: 2 additions & 2 deletions mapbox_gl_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ dev_dependencies:
sdk: flutter

environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0"
sdk: '>=2.17.0 <3.0.0'
flutter: ">=3.0.0"
39 changes: 23 additions & 16 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.2"
version: "3.3.0"
characters:
dependency: transitive
description:
Expand All @@ -16,19 +16,19 @@ packages:
source: hosted
version: "1.2.0"
collection:
dependency: transitive
dependency: "direct main"
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -45,35 +45,42 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
version: "3.2.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
mapbox_gl_dart:
dependency: transitive
description:
name: mapbox_gl_dart
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0-nullsafety.0"
version: "0.2.1"
mapbox_gl_platform_interface:
dependency: "direct main"
description:
path: mapbox_gl_platform_interface
relative: true
source: path
version: "0.14.0"
version: "0.15.0"
mapbox_gl_web:
dependency: "direct main"
description:
path: mapbox_gl_web
relative: true
source: path
version: "0.14.0"
version: "0.15.0"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -87,14 +94,14 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.2"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
version: "5.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -106,21 +113,21 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.0"
version: "6.0.1"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=2.0.0"
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
5 changes: 2 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ flutter:
default_package: mapbox_gl_web

environment:
sdk: '>=2.12.0 <3.0.0'
# Flutter versions prior to 1.10 did not support the flutter.plugin.platforms map.
flutter: ">=2.0.0"
sdk: '>=2.17.0 <3.0.0'
flutter: ">=3.0.0"