decode method

HWWidget decode()

Implementation

HWWidget decode() {
  if (object == null || object!.isNull) {
    throw GeneratorError('Widget object is null');
  }

  final type = object!.type;
  final typeName = type?.element?.name;

  if (typeName == 'HWColumn') {
    return HWColumn.fromDartObject(object!, this);
  } else if (typeName == 'HWRow') {
    return HWRow.fromDartObject(object!, this);
  } else if (typeName == 'HWText') {
    return HWText.fromDartObject(object!);
  } else if (typeName == 'HWDataOnly') {
    return HWDataOnly.fromDartObject(object!);
  } else if (typeName == 'HWAdaptive') {
    return HWAdaptive.fromDartObject(object!, this);
  } else if (typeName == 'HWFill') {
    return HWFill.fromDartObject(object!, this);
  } else if (typeName == 'HWColoredBox') {
    return HWColoredBox.fromDartObject(object!, this);
  } else if (typeName == 'HWDecoratedBox') {
    return HWDecoratedBox.fromDartObject(object!, this);
  } else if (typeName == 'HWPadding') {
    return HWPadding.fromDartObject(object!, this);
  } else if (typeName == 'HWDataExists') {
    return HWDataExists.fromDartObject(object!, this);
  } else if (typeName == 'HWBoolConditional') {
    return HWBoolConditional.fromDartObject(object!, this);
  }

  // coverage:ignore-start
  throw GeneratorError('Unknown widget type: $typeName');
  // coverage:ignore-end
}