'_Smi'不是'bool'类型的子类型-Flutter MethodChannel [英] '_Smi' is not a subtype of type 'bool' - Flutter MethodChannel
本文介绍了'_Smi'不是'bool'类型的子类型-Flutter MethodChannel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
得到这个奇怪的错误.似乎MethodChannel正在转换为int而不是bool?
Getting this strange error. Seems like the MethodChannel is converting to an int instead of a 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)
}
}
不知道是什么原因造成的.它似乎在模拟器中的调试模式下工作(此错误是在实际设备上发布的apk).
No idea what could be causing this. It seems to be working in debug mode in the emulator (this error is release apk on a real device).
推荐答案
运行flutter clean
似乎已解决此问题.我想确保在每次发行版本之前都要做!
Running flutter clean
seems to have fixed this. Make sure to do it before every release build, I guess!
这篇关于'_Smi'不是'bool'类型的子类型-Flutter MethodChannel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文