Config.fromJson constructor

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

Implementation

factory Config.fromJson(Map<String, dynamic> json) {
  final layers = [
    if (json['bloc'] == true) PresentationLayer.bloc,
    if (json['riverpod'] == true) PresentationLayer.riverpod,
    if (json['getx'] == true) PresentationLayer.getx,
  ];

  if (layers.length == 1) {
    return Config(layer: layers.single);
  }
  if (layers.length > 1) {
    return const Config(hasMultipleLayers: true);
  }
  // layer == null — will be caught by Parser.validateSchema.
  return const Config();
}