diff --git a/example/lib/generated_plugin_registrant.dart b/example/lib/generated_plugin_registrant.dart index ae1e051c7..91d1beadb 100644 --- a/example/lib/generated_plugin_registrant.dart +++ b/example/lib/generated_plugin_registrant.dart @@ -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'; diff --git a/example/lib/main.dart b/example/lib/main.dart index 2b6e4c899..f5672e4d1 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -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'; @@ -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'; @@ -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 _allPages = [ MapUiPage(), @@ -72,22 +68,6 @@ class _MapsDemoState extends State { 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 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(); diff --git a/example/lib/map_ui.dart b/example/lib/map_ui.dart index b10a0334a..5cb7ad849 100644 --- a/example/lib/map_ui.dart +++ b/example/lib/map_ui.dart @@ -346,6 +346,9 @@ class MapUiBodyState extends State { 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}"); diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9731f59c0..d8001b9b1 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -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: diff --git a/lib/src/mapbox_map.dart b/lib/src/mapbox_map.dart index ffd86c02e..c9533b18c 100644 --- a/lib/src/mapbox_map.dart +++ b/lib/src/mapbox_map.dart @@ -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(); diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index 38da956cf..30dfc9175 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -2,7 +2,6 @@ part of mapbox_gl_platform_interface; class MethodChannelMapboxGl extends MapboxGlPlatform { late MethodChannel _channel; - static bool useHybridComposition = false; Future _handleMethodCall(MethodCall call) async { switch (call.method) { @@ -141,50 +140,39 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { OnPlatformViewCreatedCallback onPlatformViewCreated, Set>? 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 >{}, - 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 >{}, + 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', diff --git a/mapbox_gl_platform_interface/pubspec.yaml b/mapbox_gl_platform_interface/pubspec.yaml index 6cbdc932b..20e948a26 100644 --- a/mapbox_gl_platform_interface/pubspec.yaml +++ b/mapbox_gl_platform_interface/pubspec.yaml @@ -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" diff --git a/mapbox_gl_web/pubspec.yaml b/mapbox_gl_web/pubspec.yaml index e6e736718..fb1897067 100644 --- a/mapbox_gl_web/pubspec.yaml +++ b/mapbox_gl_web/pubspec.yaml @@ -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" diff --git a/pubspec.lock b/pubspec.lock index 4aab14388..83b085dc6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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: @@ -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 @@ -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: @@ -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 @@ -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" diff --git a/pubspec.yaml b/pubspec.yaml index d99a102e5..6cd26f6d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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"