fromJson static method

LandscapeLayoutConfig fromJson(
  1. Map<String, dynamic> json
)

Implementation

static LandscapeLayoutConfig fromJson(Map<String, dynamic> json) {
  Map<LayoutPosition, ComponentConfig>? componentsMap;

  if (json['componentConfig'] != null) {
    componentsMap = <LayoutPosition, ComponentConfig>{};
    final componentsJson = json['componentConfig'] as Map<String, dynamic>;
    componentsJson.forEach((key, value) {
      final position = LayoutPosition.values.firstWhere(
        (e) => e.toString() == 'LayoutPosition.$key',
        orElse: () => LayoutPosition.center,
      );
      componentsMap![position] = ComponentConfig.fromJson(
        value as Map<String, dynamic>,
      );
    });
  }

  return LandscapeLayoutConfig(
    memberListPosition: TLayoutPosition.values.firstWhere(
      (e) => e.name == json['memberListPosition'],
    ),
    componentConfig: componentsMap,
  );
}