- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
按照 https://docs.flutter.dev/development/platform-integration/platform-views 中的指南进行操作后出现此编译错误
我试过用Flutter v3.0.1和v2.13.0-0.4.pre来测试,还是一样的错误。
错误显示:
e: C:\Users\wongc\Documents\Agmo_Studio_Project\ble_poc\android\app\src\main\kotlin\com\example\ble_poc\MapViewFactory.kt: (9, 1): Class 'MapViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactorye: C:\Users\wongc\Documents\Agmo_Studio_Project\ble_poc\android\app\src\main\kotlin\com\example\ble_poc\MapViewFactory.kt: (10, 5): 'create' overrides nothing
MainActivity.kt
package com.example.ble_poc
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
class MainActivity : FlutterActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
flutterEngine
.platformViewsController
.registry
.registerViewFactory("mappedin", MapViewFactory())
}
}
MapView.kt
package com.example.ble_poc
import android.content.Context
import android.graphics.Color
import android.view.View
import android.widget.TextView
import io.flutter.plugin.platform.PlatformView
internal class MapView(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)"
}
}
map View 工厂
package com.example.ble_poc
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 MapViewFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
override fun create(context: Context, viewId: Int, args: Any?): PlatformView {
val creationParams = args as Map<String?, Any?>?
return MapView(context, viewId, creationParams)
}
}
这是 Flutter 方面的错误吗?
最佳答案
这是kotlin null safety的错误
请尝试以下
class MapViewFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
override fun create(context: Context?, viewId: Int, args: Any?): PlatformView {
val creationParams = args as Map<String?, Any?>?
return MapView(context!!, viewId, creationParams)
}
}
更改源代码来自
override fun create(context: Context, viewId: Int, args: Any?):
到
override fun create(context: Context?, viewId: Int, args: Any?):
/// you are missing '?' from 'context:Context'
详细可以看PlatformViewFactory源码:
public abstract PlatformView create(@Nullable Context context, int viewId, @Nullable Object args);
context 可以为 null - 所以你缺少'?'在 kotlin 空安全中
关于android - 类没有实现抽象基类成员 public abstract fun create(p0 : Context? , p1 : Int, p2 : Any? ): PlatformView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72357394/
我试过谷歌搜索但找不到准确的答案,所以请允许我尝试在这里提问。如果问题看起来不合适,请告诉我,我会删除它。 在 JS 中,您可以通过三种不同的方式编写特定的内置功能: 字符串长度 str.toStri
在《Professional JavaScript for Web Developers》第三版一书中,它说: var name = "The window"; var object = {
我试图找到答案,但是我经常失败。我有一个带有一列字符串的数据框。我想计算该列每个条目中的字符数,并用计数替换字符串列。 data[,29]=apply(data[,29],nchar()) Out[2
class A(object): def fun(self): pass ins_a = A.fun ins_b = A().fun 我遇到了这段代码,但我无法理解这两个对象之
表达式fun和&fun的类型是否相同? 考虑以下代码: template void check(T) { static_assert(is_same::value); } void fun(
我遇到了一段代码,如下所示 qsort(array, 10, sizeof(int), sort); 这里 sort 又是一个函数。但我一直觉得任何被调用的函数都应该在函数名称后加上 () ,或者我错
void fun(){ std::cout << "hello" << std::endl; } namespace enc{ using ::fun; } 上面的这段代码没有错误。我
源代码: static bool cmp(pair& m, pair& n) { return m.second > n.second; } priority_queue, vector>,
setTimeout 的行为有点令人困惑,我读过的所有资源都表明,当没有指定延迟时,任务将被附加到队列末尾,并在解释器无事可做时执行(空队列?)。但是,请看以下示例: setTimeout(funct
我正在使用一些内置函数 fun(void **args) 并调用这个传递参数的函数 fun(args); 所以 是什么意思void **args 以及如何检查值 args 在 C 中有什么。 void
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: How come pointer to a function be called without deref
我正在使用 dlsym 来填充函数指针,它是 call 的一个成员变量。像下面一样 class ABC { private: void (*m_fun) (int); } 现在如果我分配 m_
在reactjs中使用功能组件时,我有一个onClick事件处理程序。 我按以下方式调用它; onClick={ props.function } 而不是; onClick={ props.funct
哪个语句更有效 --> perl 中的 goto &fun($val) 或 fun($val)?何时使用哪个语句以获得更好的性能?请告诉我答案! 最佳答案 我认为这是一个错误的问题。 fun($val
我正在考虑有关 suspend 的事情Arrow 的文档详细解释了:suspend () -> A提供与 IO 相同的保证. 因此,根据文档,只需使用 suspend我们正在将不纯函数转换为纯函数:
谁能告诉我 我使用这个方法“[aClass respondsToSelector:@selector(fun)]”来查找任何类(class)中是否有乐趣 但是当 fun 有三个参数时我该如何处理呢??
下面是在使用new创建的对象上定义方法的两种方法。关键词。我正在尝试比较每种方法的工作原理和效果。 1) 函数式 mixin asCircle被定义为。然后.call将 mixin 注入(inject
如主题标题。当我写:void fun(int *tab){} 和写 void fun(int tab[]){} 一样吗? 最佳答案 是的。 void fun(int *tab){} void fun(
在 lib Bullet 中定义了一个类型: typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDi
我愿意: Prelude> "sone" ++ "otehr" "soneotehr" 但是这样的代码: addOneToElement :: [a] -> [a] addOneToElement e
我是一名优秀的程序员,十分优秀!