繁体   English   中英

无法声明 UnsignedInt 数据类型以在 dart 中将数据模型发送到服务器

[英]Unable to declare UnsignedInt data type for sending data model to server in dart

我正在尝试定义UnsignedInt? id UnsignedInt? id在我的数据模型中。 但是当我尝试将模型发送到服务器时,它一直给我这个错误。

[严重] json_serializable:json_serializable 在 lib/src/model/otp.dart 上(缓存):

无法为countryID生成fromJson代码。 要支持UnsignedInt类型,您可以:

这是我想将模型发送到服务器的代码:

Future<OTP?> getCode(String countryCode, String phone) async {
    const url = HttpUtils.baseUrl + HttpUtils.getcode;
    _myOtp = null;
    try {
      final response = await http.post(
        Uri.parse(url),
        headers: {"Content-Type": "application/json"},
        body: json.encode(OTP(phoneNo: phone,).toJson()),
      );
      _myOtp = OTP.fromJson(json.decode(response.body)["otp"]);
    } catch (error) {
      if (kDebugMode) {
        print(error.toString());
      }
    }
    return _myOtp;
  }

不支持UnsignedInt

开箱即用,json_serializable 支持 dart:core 库中的许多常见类型:BigInt、bool、DateTime、double、Duration、Enum、int、Iterable、List、Map、num、Object、Set、String、Uri

有关详细信息,请参阅json_serializable

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM