maybeFromDynamic static method

JsonSetValueBuilderModel? maybeFromDynamic(
  1. dynamic map, {
  2. Map<String, dynamic> args = const {},
  3. JsonWidgetRegistry? registry,
})

Implementation

static JsonSetValueBuilderModel? maybeFromDynamic(
  dynamic map, {
  Map<String, dynamic> args = const {},
  JsonWidgetRegistry? registry,
}) {
  JsonSetValueBuilderModel? result;

  if (map != null) {
    if (map is String) {
      map = yaon.parse(
        map,
        normalize: true,
      );
    }

    if (map is JsonSetValueBuilderModel) {
      result = map;
    } else {
      registry ??= JsonWidgetRegistry.instance;
      map = registry.processArgs(map, <String>{}).value;
      result = JsonSetValueBuilderModel(
        args,
        cleanup: JsonClass.parseBool(
          map['cleanup'],
          whenNull: true,
        ),
        values: map['values'],
        child: () {
          dynamic parsed = JsonWidgetData.maybeFromDynamic(
            map['child'],
            registry: registry,
          );

          return parsed;
        }(),
      );
    }
  }

  return result;
}