扑打jsonserialization

发布于 2025-01-25 15:13:02 字数 707 浏览 2 评论 0原文

我目前正在构建一个应用程序,用户可以在其设备上存储列表项目作为收藏夹。调试我的应用程序我正在以下错误运行:

发生了例外。
_casterror(type'null'不是类型'widget'的亚型)

这是我的代码:

LogEntry _$LogEntryFromJson(Map<String, dynamic> json) {
  return LogEntry(
      mechanismId: json['mechanismId'] as int?,
      timestamp: DateTime.parse(json['timestamp'] as String),
      navigation: json['navigation'] as Widget);
}

Map<String, dynamic> _$LogEntryToJson(LogEntry instance) => <String, dynamic>{
      'mechanismId': instance.mechanismId,
      'timestamp': instance.timestamp.toIso8601String(),
      'navigation:': instance.navigation,
    };

机械机制是列表项目的各个ID,导航代表详细信息页面的路由。

I am currently building an app where the user is able to store List items as favorites on their device. Debugging my app I am running in the following error:

Exception has occurred.
_CastError (type 'Null' is not a subtype of type 'Widget' in type cast)

This is my code:

LogEntry _$LogEntryFromJson(Map<String, dynamic> json) {
  return LogEntry(
      mechanismId: json['mechanismId'] as int?,
      timestamp: DateTime.parse(json['timestamp'] as String),
      navigation: json['navigation'] as Widget);
}

Map<String, dynamic> _$LogEntryToJson(LogEntry instance) => <String, dynamic>{
      'mechanismId': instance.mechanismId,
      'timestamp': instance.timestamp.toIso8601String(),
      'navigation:': instance.navigation,
    };

The mechanismID is the respective ID of a List item and the navigation stands for the route of the detail page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Spring初心 2025-02-01 15:13:02
LogEntry _$LogEntryFromJson(Map<String, dynamic> json) {
  return LogEntry(
      mechanismId: json['mechanismId'] as int?,
      timestamp: DateTime.parse(json['timestamp'] as String),
      navigation: json['navigation'] as Widget?);
}
LogEntry _$LogEntryFromJson(Map<String, dynamic> json) {
  return LogEntry(
      mechanismId: json['mechanismId'] as int?,
      timestamp: DateTime.parse(json['timestamp'] as String),
      navigation: json['navigation'] as Widget?);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文