build method

Widget build(
  1. String key,
  2. dynamic value,
  3. Widget? widget,
  4. dynamic updateItem(
    1. String
    ),
  5. dynamic saveItem(
    1. String?
    ),
)

Implementation

Widget build(
  String key,
  value,
  Widget? widget,
  Function(String) updateItem,
  Function(String?) saveItem,
) {
  if (widget == null) {
    var controller = TextEditingController(
      text: '${value ?? ''}',
    );

    var inputDecoration =
        options.inputDecorationField?[key] ?? options.inputDecoration;

    var formFieldKey = GlobalKey<FormFieldState>();
    return TextFormField(
      style: options.inputTextStyle,
      keyboardType: options.keyboardType?[key],
      key: formFieldKey,
      controller: controller,
      decoration: inputDecoration,
      readOnly: options.readOnly,
      onFieldSubmitted: (value) {
        updateItem(value);
      },
      onSaved: (newValue) {
        saveItem(newValue);
      },
      validator: (value) => options.validators?[key]?.call(value),
    );
  }
  return widget;
}