Open DavidPerezP124 opened 2 years ago
https://docs.flutter.dev/development/platform-integration/android/platform-views/
https://github.com/flutter/website/tree/main/src/development/platform-integration/android/platform-views.md
Overriden method on NativeFactoryView should have the method change from 3.* . Possibly related to this https://github.com/flutter/engine/pull/31530.
package dev.flutter.example import android.content.Context import android.view.View import io.flutter.plugin.common.StandardMessageCodec import io.flutter.plugin.platform.PlatformView import io.flutter.plugin.platform.PlatformViewFactory class NativeViewFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) { override fun create(context: Context, viewId: Int, args: Any?): PlatformView { val creationParams = args as Map<String?, Any?>? return NativeView(context, viewId, creationParams) } }
It should be something similar to this:
package dev.flutter.example import android.content.Context import android.view.View import io.flutter.plugin.common.StandardMessageCodec import io.flutter.plugin.platform.PlatformView import io.flutter.plugin.platform.PlatformViewFactory class NativeViewFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) { override fun create(p0: Context?, p1: Int, p2: Any?): PlatformView { val creationParams = p2 as Map<String?, Any?>? return NativeView(context, p1, creationParams) } }
And same for the NativeView snippet, it should have an updated initializer for a nullable Context
Context
package dev.flutter.example import android.content.Context import android.graphics.Color import android.view.View import android.widget.TextView import io.flutter.plugin.platform.PlatformView internal class NativeView(context: Context, id: Int, creationParams: Map<String?, Any?>?) : PlatformView { private val textView: TextView override fun getView(): View { return textView } override fun dispose() {} init { textView = TextView(context) textView.textSize = 72f textView.setBackgroundColor(Color.rgb(255, 255, 255)) textView.text = "Rendered on a native Android view (id: $id)" } }
Should be:
package dev.flutter.example import android.content.Context import android.graphics.Color import android.view.View import android.widget.TextView import io.flutter.plugin.platform.PlatformView internal class NativeView(context: Context?, id: Int, creationParams: Map<String?, Any?>?) : PlatformView { private val textView: TextView override fun getView(): View { return textView } override fun dispose() {} init { textView = TextView(context) textView.textSize = 72f textView.setBackgroundColor(Color.rgb(255, 255, 255)) textView.text = "Rendered on a native Android view (id: $id)" } }
No response
/cc @blasten for more context on this
Page URL
https://docs.flutter.dev/development/platform-integration/android/platform-views/
Page source
https://github.com/flutter/website/tree/main/src/development/platform-integration/android/platform-views.md
Describe the problem
Overriden method on NativeFactoryView should have the method change from 3.* . Possibly related to this https://github.com/flutter/engine/pull/31530.
It should be something similar to this:
And same for the NativeView snippet, it should have an updated initializer for a nullable
Context
Should be:
Expected fix
No response
Additional context
No response