branchCodeFormEntry method

Widget branchCodeFormEntry({
  1. String title = 'Branch Code',
  2. String subTitle = 'the branch code',
  3. dynamic onSaved(
    1. String?
    )?,
  4. String? defaultValue,
})

Implementation

Widget branchCodeFormEntry({
  String title = 'Branch Code',
  String subTitle = 'the branch code',
  Function(String?)? onSaved,
  String? defaultValue,
}) {
  return formEntry(
    title: title,
    subTitle: subTitle,
    inputWidget: TextFormField(
      onChanged: (_) {
        widget.formKey.currentState!.save();
        if (widget.onModified != null) {
          widget.onModified!();
        }
      },
      style: Theme.of(context).textTheme.bodyLarge,
      enabled: isEdit,
      controller: TextEditingController(text: defaultValue),
      decoration: elegantInputDecoration(
        hintText: 'Branch Code',
        prefix: const Icon(Icons.code),
      ),
      validator: (value) => value!.isEmpty
          ? 'Branch code is required'
          : (value.isValidNumber() ? null : 'Invalid branch code'),
      onSaved: onSaved,
    ),
  );
}