Skip to content

Commit 14ddb3d

Browse files
committed
Fix flutter 3.24
1 parent 019aabe commit 14ddb3d

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ dependencies {
8181
implementation "com.mapbox.maps:android:11.6.0-rc.1"
8282

8383
implementation "androidx.annotation:annotation:1.7.1"
84-
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.0"
84+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.8.4"
8585
}

android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxMapController.kt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import androidx.lifecycle.DefaultLifecycleObserver
77
import androidx.lifecycle.Lifecycle
88
import androidx.lifecycle.LifecycleOwner
99
import androidx.lifecycle.LifecycleRegistry
10-
import androidx.lifecycle.ViewTreeLifecycleOwner
10+
import androidx.lifecycle.setViewTreeLifecycleOwner
1111
import com.mapbox.bindgen.Value
1212
import com.mapbox.common.SettingsServiceFactory
1313
import com.mapbox.common.SettingsServiceStorageType
@@ -67,22 +67,18 @@ class MapboxMapController(
6767
/*
6868
Mirrors lifecycle of the parent, with one addition - switches to DESTROYED state
6969
when `dispose` is called.
70-
`parentLifecycle` is the lifecycle of the Flutter activity, which may live much longer then
70+
`lifecycle` is the lifecycle of the Flutter activity, which may live much longer then
7171
the MapView attached.
7272
*/
7373
private class LifecycleHelper(
74-
val parentLifecycle: Lifecycle,
74+
override val lifecycle: Lifecycle,
7575
val shouldDestroyOnDestroy: Boolean,
7676
) : LifecycleOwner, DefaultLifecycleObserver {
7777

7878
val lifecycleRegistry: LifecycleRegistry = LifecycleRegistry(this)
7979

8080
init {
81-
parentLifecycle.addObserver(this)
82-
}
83-
84-
override fun getLifecycle(): Lifecycle {
85-
return lifecycleRegistry
81+
lifecycle.addObserver(this)
8682
}
8783

8884
override fun onCreate(owner: LifecycleOwner) {
@@ -108,7 +104,7 @@ class MapboxMapController(
108104
override fun onDestroy(owner: LifecycleOwner) = propagateDestroyEvent()
109105

110106
fun dispose() {
111-
parentLifecycle.removeObserver(this)
107+
lifecycle.removeObserver(this)
112108
propagateDestroyEvent()
113109
}
114110

@@ -173,14 +169,14 @@ class MapboxMapController(
173169
}
174170
lifecycleHelper = LifecycleHelper(lifecycleProvider.getLifecycle()!!, shouldDestroyOnDestroy)
175171

176-
mapView?.let { ViewTreeLifecycleOwner.set(it, lifecycleHelper) }
172+
mapView?.setViewTreeLifecycleOwner(lifecycleHelper)
177173
}
178174

179175
override fun onFlutterViewDetached() {
180176
super.onFlutterViewDetached()
181177
lifecycleHelper?.dispose()
182178
lifecycleHelper = null
183-
ViewTreeLifecycleOwner.set(mapView!!, null)
179+
mapView!!.setViewTreeLifecycleOwner(null)
184180
}
185181

186182
override fun dispose() {
@@ -251,4 +247,4 @@ class MapboxMapController(
251247
SettingsServiceFactory.getInstance(SettingsServiceStorageType.NON_PERSISTENT)
252248
.set("com.mapbox.common.telemetry.internal.custom_user_agent_fragment", Value.valueOf("FlutterPlugin/$version"))
253249
}
254-
}
250+
}

0 commit comments

Comments
 (0)