Flutter Json序列化
Flutter JsonSerialization
我目前正在构建一个应用程序,用户可以在其中将列表项作为收藏夹存储在他们的设备上。调试我的应用程序我 运行 出现以下错误:
Exception has occurred.
_CastError (type 'Null' is not a subtype of type 'Widget' in type cast)
这是我的代码:
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,
};
mechanismID为List项各自的ID,navigation代表详情页的路径
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?);
}
我目前正在构建一个应用程序,用户可以在其中将列表项作为收藏夹存储在他们的设备上。调试我的应用程序我 运行 出现以下错误:
Exception has occurred.
_CastError (type 'Null' is not a subtype of type 'Widget' in type cast)
这是我的代码:
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,
};
mechanismID为List项各自的ID,navigation代表详情页的路径
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?);
}