buildEditText method Null safety

  1. @protected
Widget buildEditText(
  1. {required BuildContext context,
  2. required String id,
  3. String? defaultValue,
  4. required TranslationEntry label,
  5. int? maxLines = 1,
  6. int? minLines,
  7. List<ValueValidator>? validators,
  8. required Map<String, dynamic> values}
)

Implementation

@protected
Widget buildEditText({
  required BuildContext context,
  required String id,
  String? defaultValue,
  required TranslationEntry label,
  int? maxLines = 1,
  int? minLines,
  List<ValueValidator>? validators,
  required Map<String, dynamic> values,
}) {
  if (values[id] == null && defaultValue != null) {
    values[id] = defaultValue;
  }

  var translator = Translator.of(context);
  return TextFormField(
    autovalidateMode: AutovalidateMode.always,
    decoration: InputDecoration(
      labelText: translator.translate(label),
    ),
    initialValue: values[id]?.toString(),
    maxLines: maxLines,
    minLines: minLines,
    onChanged: (value) => values[id] = value,
    smartDashesType: SmartDashesType.disabled,
    smartQuotesType: SmartQuotesType.disabled,
    validator: (value) => validators?.isNotEmpty == true
        ? Validator(validators: validators!).validate(
            context: context,
            label: translator.translate(label),
            value: value,
          )
        : null,
  );
}