Skip to content

Commit 21504eb

Browse files
committed
Switch to flutter 3 and new dart
Remove hybrid composition
1 parent 1f96937 commit 21504eb

File tree

10 files changed

+67
-93
lines changed

10 files changed

+67
-93
lines changed

example/lib/generated_plugin_registrant.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
// ignore_for_file: directives_ordering
66
// ignore_for_file: lines_longer_than_80_chars
7+
// ignore_for_file: depend_on_referenced_packages
78

89
import 'package:device_info_plus_web/device_info_plus_web.dart';
910
import 'package:location_web/location_web.dart';

example/lib/main.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,6 @@ class _MapsDemoState extends State<MapsDemo> {
7272
super.initState();
7373
}
7474

75-
/// Determine the android version of the phone and turn off HybridComposition
76-
/// on older sdk versions to improve performance for these
77-
///
78-
/// !!! Hybrid composition is currently broken do no use !!!
79-
Future<void> initHybridComposition() async {
80-
if (!kIsWeb && Platform.isAndroid) {
81-
final androidInfo = await DeviceInfoPlugin().androidInfo;
82-
final sdkVersion = androidInfo.version.sdkInt;
83-
if (sdkVersion != null && sdkVersion >= 29) {
84-
MapboxMap.useHybridComposition = true;
85-
} else {
86-
MapboxMap.useHybridComposition = false;
87-
}
88-
}
89-
}
90-
9175
void _pushPage(BuildContext context, ExamplePage page) async {
9276
if (!kIsWeb) {
9377
final location = Location();

example/lib/map_ui.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ class MapUiBodyState extends State<MapUiBody> {
346346
myLocationEnabled: _myLocationEnabled,
347347
myLocationTrackingMode: _myLocationTrackingMode,
348348
myLocationRenderMode: MyLocationRenderMode.GPS,
349+
onStyleLoadedCallback: () async {
350+
print("onStyleLoadedCallback");
351+
},
349352
onMapClick: (point, latLng) async {
350353
print(
351354
"Map click: ${point.x},${point.y} ${latLng.latitude}/${latLng.longitude}");

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ publish_to: 'none'
44
version: 1.0.0+1
55

66
environment:
7-
sdk: '>=2.12.0 <3.0.0'
7+
sdk: '>=2.17.0-0 <3.0.0'
88

99
dependencies:
1010
flutter:

lib/src/mapbox_map.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,6 @@ class MapboxMap extends StatefulWidget {
222222
/// * All fade/transition animations have completed
223223
final OnMapIdleCallback? onMapIdle;
224224

225-
/// Set `MapboxMap.useHybridComposition` to `false` in order use Virtual-Display
226-
/// (better for Android 9 and below but may result in errors on Android 12)
227-
/// or leave it `true` (default) to use Hybrid composition (Slower on Android 9 and below).
228-
static bool get useHybridComposition =>
229-
MethodChannelMapboxGl.useHybridComposition;
230-
static set useHybridComposition(bool useHybridComposition) =>
231-
MethodChannelMapboxGl.useHybridComposition = useHybridComposition;
232-
233225
@override
234226
State createState() => _MapboxMapState();
235227
}

mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ part of mapbox_gl_platform_interface;
22

33
class MethodChannelMapboxGl extends MapboxGlPlatform {
44
late MethodChannel _channel;
5-
static bool useHybridComposition = false;
65

76
Future<dynamic> _handleMethodCall(MethodCall call) async {
87
switch (call.method) {
@@ -141,50 +140,39 @@ class MethodChannelMapboxGl extends MapboxGlPlatform {
141140
OnPlatformViewCreatedCallback onPlatformViewCreated,
142141
Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers) {
143142
if (defaultTargetPlatform == TargetPlatform.android) {
144-
if (useHybridComposition) {
145-
return PlatformViewLink(
146-
viewType: 'plugins.flutter.io/mapbox_gl',
147-
surfaceFactory: (
148-
BuildContext context,
149-
PlatformViewController controller,
150-
) {
151-
return AndroidViewSurface(
152-
controller: controller as AndroidViewController,
153-
gestureRecognizers: gestureRecognizers ??
154-
const <Factory<OneSequenceGestureRecognizer>>{},
155-
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
156-
);
157-
},
158-
onCreatePlatformView: (PlatformViewCreationParams params) {
159-
final SurfaceAndroidViewController controller =
160-
PlatformViewsService.initSurfaceAndroidView(
161-
id: params.id,
162-
viewType: 'plugins.flutter.io/mapbox_gl',
163-
layoutDirection: TextDirection.ltr,
164-
creationParams: creationParams,
165-
creationParamsCodec: const StandardMessageCodec(),
166-
onFocus: () => params.onFocusChanged(true),
167-
);
168-
controller.addOnPlatformViewCreatedListener(
169-
params.onPlatformViewCreated,
170-
);
171-
controller.addOnPlatformViewCreatedListener(
172-
onPlatformViewCreated,
173-
);
174-
175-
controller.create();
176-
return controller;
177-
},
178-
);
179-
} else {
180-
return AndroidView(
181-
viewType: 'plugins.flutter.io/mapbox_gl',
182-
onPlatformViewCreated: onPlatformViewCreated,
183-
gestureRecognizers: gestureRecognizers,
184-
creationParams: creationParams,
185-
creationParamsCodec: const StandardMessageCodec(),
186-
);
187-
}
143+
return PlatformViewLink(
144+
viewType: 'plugins.flutter.io/mapbox_gl',
145+
surfaceFactory: (
146+
BuildContext context,
147+
PlatformViewController controller,
148+
) {
149+
return AndroidViewSurface(
150+
controller: controller as AndroidViewController,
151+
gestureRecognizers: gestureRecognizers ??
152+
const <Factory<OneSequenceGestureRecognizer>>{},
153+
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
154+
);
155+
},
156+
onCreatePlatformView: (PlatformViewCreationParams params) {
157+
final ExpensiveAndroidViewController controller =
158+
PlatformViewsService.initExpensiveAndroidView(
159+
id: params.id,
160+
viewType: 'plugins.flutter.io/mapbox_gl',
161+
layoutDirection: TextDirection.ltr,
162+
creationParams: creationParams,
163+
creationParamsCodec: const StandardMessageCodec(),
164+
onFocus: () => params.onFocusChanged(true),
165+
);
166+
controller.addOnPlatformViewCreatedListener(
167+
params.onPlatformViewCreated,
168+
);
169+
controller.addOnPlatformViewCreatedListener(
170+
onPlatformViewCreated,
171+
);
172+
173+
return controller;
174+
},
175+
);
188176
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
189177
return UiKitView(
190178
viewType: 'plugins.flutter.io/mapbox_gl',

mapbox_gl_platform_interface/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ dependencies:
99
meta: ^1.0.5
1010

1111
environment:
12-
sdk: '>=2.12.0 <3.0.0'
13-
flutter: ">=2.0.0"
12+
sdk: '>=2.17.0 <3.0.0'
13+
flutter: ">=3.0.0"

mapbox_gl_web/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ dev_dependencies:
3232
sdk: flutter
3333

3434
environment:
35-
sdk: ">=2.12.0 <3.0.0"
36-
flutter: ">=2.0.0"
35+
sdk: '>=2.17.0 <3.0.0'
36+
flutter: ">=3.0.0"

pubspec.lock

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: archive
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "3.1.2"
10+
version: "3.3.0"
1111
characters:
1212
dependency: transitive
1313
description:
@@ -16,19 +16,19 @@ packages:
1616
source: hosted
1717
version: "1.2.0"
1818
collection:
19-
dependency: transitive
19+
dependency: "direct main"
2020
description:
2121
name: collection
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.15.0"
24+
version: "1.16.0"
2525
crypto:
2626
dependency: transitive
2727
description:
2828
name: crypto
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "3.0.1"
31+
version: "3.0.2"
3232
flutter:
3333
dependency: "direct main"
3434
description: flutter
@@ -45,35 +45,42 @@ packages:
4545
name: image
4646
url: "https://pub.dartlang.org"
4747
source: hosted
48-
version: "3.0.2"
48+
version: "3.2.0"
4949
js:
5050
dependency: transitive
5151
description:
5252
name: js
5353
url: "https://pub.dartlang.org"
5454
source: hosted
55-
version: "0.6.3"
55+
version: "0.6.4"
5656
mapbox_gl_dart:
5757
dependency: transitive
5858
description:
5959
name: mapbox_gl_dart
6060
url: "https://pub.dartlang.org"
6161
source: hosted
62-
version: "0.2.0-nullsafety.0"
62+
version: "0.2.1"
6363
mapbox_gl_platform_interface:
6464
dependency: "direct main"
6565
description:
6666
path: mapbox_gl_platform_interface
6767
relative: true
6868
source: path
69-
version: "0.14.0"
69+
version: "0.15.0"
7070
mapbox_gl_web:
7171
dependency: "direct main"
7272
description:
7373
path: mapbox_gl_web
7474
relative: true
7575
source: path
76-
version: "0.14.0"
76+
version: "0.15.0"
77+
material_color_utilities:
78+
dependency: transitive
79+
description:
80+
name: material_color_utilities
81+
url: "https://pub.dartlang.org"
82+
source: hosted
83+
version: "0.1.4"
7784
meta:
7885
dependency: transitive
7986
description:
@@ -87,14 +94,14 @@ packages:
8794
name: path
8895
url: "https://pub.dartlang.org"
8996
source: hosted
90-
version: "1.8.0"
97+
version: "1.8.2"
9198
petitparser:
9299
dependency: transitive
93100
description:
94101
name: petitparser
95102
url: "https://pub.dartlang.org"
96103
source: hosted
97-
version: "4.1.0"
104+
version: "5.0.0"
98105
sky_engine:
99106
dependency: transitive
100107
description: flutter
@@ -106,21 +113,21 @@ packages:
106113
name: typed_data
107114
url: "https://pub.dartlang.org"
108115
source: hosted
109-
version: "1.3.0"
116+
version: "1.3.1"
110117
vector_math:
111118
dependency: transitive
112119
description:
113120
name: vector_math
114121
url: "https://pub.dartlang.org"
115122
source: hosted
116-
version: "2.1.1"
123+
version: "2.1.2"
117124
xml:
118125
dependency: transitive
119126
description:
120127
name: xml
121128
url: "https://pub.dartlang.org"
122129
source: hosted
123-
version: "5.1.0"
130+
version: "6.0.1"
124131
sdks:
125-
dart: ">=2.14.0 <3.0.0"
126-
flutter: ">=2.0.0"
132+
dart: ">=2.17.0 <3.0.0"
133+
flutter: ">=3.0.0"

pubspec.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,5 @@ flutter:
3434
default_package: mapbox_gl_web
3535

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

0 commit comments

Comments
 (0)