Flutter: Unsupported value: false/true

Posted 一叶飘舟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter: Unsupported value: false/true相关的知识,希望对你有一定的参考价值。

在使用FlutterBoost传参时,直接传递bool值时出现崩溃。

FlutterBoost.singleton.open(
            'flutter://personnel_page',
            urlParams: <String, dynamic>
              'isBd': i%2==0 ? true : false,
  
            ,
          ),

崩溃日志如下: 

 Caused by: java.lang.IllegalArgumentException: Unsupported value: false
        at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:278)
        at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:275)
        at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:275)
        at io.flutter.plugin.common.StandardMethodCodec.encodeMethodCall(StandardMethodCodec.java:38)
        at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:99)
        at com.idlefish.flutterboost.FlutterBoostPlugin.invokeMethod(FlutterBoostPlugin.java:138)
        at com.idlefish.flutterboost.FlutterBoostPlugin.invokeMethodUnsafe(FlutterBoostPlugin.java:96)
        at com.idlefish.flutterboost.ContainerRecord$MethodChannelProxy.invokeChannelUnsafe(ContainerRecord.java:292)
        at com.idlefish.flutterboost.ContainerRecord$MethodChannelProxy.create(ContainerRecord.java:231)
        at com.idlefish.flutterboost.ContainerRecord$MethodChannelProxy.access$100(ContainerRecord.java:226)
        at com.idlefish.flutterboost.ContainerRecord.onCreate(ContainerRecord.java:106)
        at com.idlefish.flutterboost.containers.FlutterActivityAndFragmentDelegate.onCreateView(FlutterActivityAndFragmentDelegate.java:163)
        at com.idlefish.flutterboost.containers.BoostFlutterActivity.createFlutterView(BoostFlutterActivity.java:229)
        at com.idlefish.flutterboost.containers.BoostFlutterActivity.onCreate(BoostFlutterActivity.java:149)
        at com.xx.ss.SSFlutterActivity.onCreate(SSFlutterActivity.java:32)
        at android.app.Activity.performCreate(Activity.java:8142)
        at android.app.Activity.performCreate(Activity.java:8114)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1308)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3550)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3749) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2181) 
        ......

原以为是FlutterBoost框架的bug,百度了一番,原来是低版本flutter的bug。

这个是因为StandardMessageCodec的boolean检查有问题导致Native像Flutter传参map里value有boolean的时候崩溃,commit已经merge到master了

https://github.com/flutter/engine/commit/13453596424988afa5eebafb5511b0bacbab19ae

高版本还没有验证...

以上是关于Flutter: Unsupported value: false/true的主要内容,如果未能解决你的问题,请参考以下文章

python TypeError: unsupported operand type(s) for +: 'geoprocessing value object' and 's

flutter Invalid value: Valid value range is empty: -1

Flutter json 2 model with Built Value

Dart/Flutter:build_value vs json_serializable

在 Flutter/Dart 中的列表内创建地图

Flutter Switch开关