fromJson static method
dynamic
fromJson(
- String widgetType,
- Map<
String, dynamic> json, - DynamicAttributes parser,
- ActionMapper actionMapper,
override
fromJson method
Implementation
static fromJson(String widgetType, Map<String, dynamic> json,
DynamicAttributes parser, ActionMapper actionMapper) {
if (widgetType != NType.scaffold) {
throw Exception('Invalid widget type');
}
final attributes = <String, dynamic>{};
final properties = json['properties'] as Map<String, dynamic>?;
properties?.forEach((key, value) {
if (key != 'key' && value != null) {
attributes[key] = parser.fromJson(key, value, actionMapper);
}
});
final appBarAttributes = const AppBarDefaultAttributes().get;
final appBarProperties =
json['app_bar_attributes'] as Map<String, dynamic>?;
appBarProperties?.forEach((key, value) {
if (key != 'key' && value != null) {
appBarAttributes[key] = parser.fromJson(key, value, actionMapper);
}
});
final bottomBarAttributes = const AppBarDefaultAttributes().get;
final bottomBarProperties =
json['bottom_bar_attributes'] as Map<String, dynamic>?;
bottomBarProperties?.forEach((key, value) {
if (key != 'key' && value != null) {
bottomBarAttributes[key] = parser.fromJson(key, value, actionMapper);
}
});
final rectProperties = RectProperties.fromJson(json['rect_properties']);
return ScaffoldOpenNode(
id: json['id'],
name: json['name'],
description: json['description'],
parentID: json['parent_id'],
attributes: attributes,
rectProperties: rectProperties,
updatedAt: DateTime.parse(json['updated_at']),
childOrder: json['child_order'] != null
? (json['child_order'] as num).toDouble()
: null,
pageID: json['page_id'],
stabilID: json['stabil_id'],
componentID: json['component_id'],
isLocked: json['is_locked'],
appBarAttributes: appBarAttributes,
bottomBarAttributes: bottomBarAttributes,
);
}