sSNFormEntry method

Widget sSNFormEntry({
  1. String title = 'SSN',
  2. String subTitle = 'the social security number',
  3. dynamic onSaved(
    1. String?
    )?,
  4. String? defaultValue,
})

Implementation

Widget sSNFormEntry({
  String title = 'SSN',
  String subTitle = 'the social security number',
  Function(String?)? onSaved,
  String? defaultValue,
}) {
  return formEntry(
    title: title,
    subTitle: subTitle,
    inputWidget: TextFormField(
      style: Theme.of(context).textTheme.bodyLarge,
      enabled: isEdit,
      onChanged: (_) {
        widget.formKey.currentState!.save();
        if (widget.onModified != null) {
          widget.onModified!();
        }
      },
      controller: TextEditingController(text: defaultValue),
      decoration: elegantInputDecoration(
        hintText: 'SSN e.g. XXX-XX-XXXX',
        prefix: const Icon(Icons.security),
      ),
      validator: (value) => value!.isEmpty
          ? null
          : (value.isValidSSNNumber() ? null : 'Invalid SSN'),
      onSaved: onSaved,
    ),
  );
}