FieldModel constructor

FieldModel(
  1. {@required String label,
  2. String name: '',
  3. String sameTo: '',
  4. String sameToError: '',
  5. Types type: Types.text,
  6. String errorMessage: '',
  7. bool mandatory: false,
  8. InputActions action: InputActions.auto,
  9. String hint: '',
  10. bool vallidate: false,
  11. int maxLength: 0,
  12. String maxLengthMessage: '',
  13. int minLength: 0,
  14. String minLengthMessage: '',
  15. bool password: false,
  16. bool readOnly: false,
  17. List<FieldOptionsModel> options: const [],
  18. String dateTimeFormat: 'MM/dd/yyyy',
  19. DateTypes dateType: DateTypes.eighteenYearsBefore,
  20. dynamic value}
)

Implementation

FieldModel({
  @required this.label,
  this.name = '',
  this.sameTo = '',
  this.sameToError = '',
  this.type = Types.text,
  this.errorMessage = '',
  this.mandatory = false,
  this.action = InputActions.auto,
  this.hint = '',
  this.vallidate = false,
  this.maxLength = 0,
  this.maxLengthMessage = '',
  this.minLength = 0,
  this.minLengthMessage = '',
  this.password = false,
  this.readOnly = false,
  this.options = const [],
  this.dateTimeFormat = 'MM/dd/yyyy',
  this.dateType = DateTypes.eighteenYearsBefore,
  this.value,
}) {
  if (this.name.isEmpty) {
    this.name = this.label;
  }
  if (this.type == Types.dropdown && this.options.isEmpty) {
    throw Exception('You need to set items for a dropdown');
  }
}