FieldModel constructor
FieldModel({
- required String label,
- double? padding,
- String name = '',
- String sameTo = '',
- String sameToError = '',
- Types type = Types.text,
- String errorMessage = '',
- bool mandatory = false,
- InputActions action = InputActions.auto,
- String hint = '',
- bool vallidate = false,
- int maxLength = 0,
- String maxLengthMessage = '',
- int minLength = 0,
- String minLengthMessage = '',
- bool password = false,
- bool readOnly = false,
- List<
FieldOptionsModel> options = const [], - String dateTimeFormat = 'MM/dd/yyyy',
- TextCapitalization capitalization = TextCapitalization.none,
- DateTypes dateType = DateTypes.eighteenYearsBefore,
- Color readOnlyColor = const Color(0xFFE9EAEE),
- dynamic value,
- List<
TextInputFormatter> ? formatters,
Implementation
FieldModel({
required this.label,
this.padding,
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.capitalization = TextCapitalization.none,
this.dateType = DateTypes.eighteenYearsBefore,
this.readOnlyColor = const Color(0xFFE9EAEE),
this.value,
this.formatters,
}) {
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');
}
}