gpt4 book ai didi

android - '_Smi' 不是类型 'bool' 的子类型 - Flutter MethodChannel

转载 作者:IT王子 更新时间:2023-10-29 06:44:13 25 4
gpt4 key购买 nike

得到这个奇怪的错误。似乎 MethodChannel 正在转换为 int 而不是 bool?

06-07 00:16:26.589  3678  4993 E flutter : [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
06-07 00:16:26.589 3678 4993 E flutter : type '_Smi' is not a subtype of type 'bool' where
06-07 00:16:26.589 3678 4993 E flutter : _Smi is from dart:core
06-07 00:16:26.589 3678 4993 E flutter : bool is from dart:core
06-07 00:16:26.589 3678 4993 E flutter :
06-07 00:16:26.589 3678 4993 E flutter : #0 ...

相关代码:

//the line in question
bool permission = await platform.invokeMethod("askStoragePermission");

//the following is the native kotlin that is called.
//The device previously had received permission so it should be going to
//the 'else' section (and no permission request dialogue appeared)
"askStoragePermission" -> {
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE), 35)
currentResult = result
} else {
result.success(true)
}
}

不知道是什么原因造成的。它似乎在模拟器中以 Debug模式工作(此错误是在真实设备上发布 apk)。

最佳答案

运行 flutter clean 似乎解决了这个问题。确保在每次发布构建之前都这样做,我猜!

关于android - '_Smi' 不是类型 'bool' 的子类型 - Flutter MethodChannel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50730976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com