FormBuilderSignaturePad constructor Null safety

FormBuilderSignaturePad(
  1. {Key? key,
  2. required String name,
  3. FormFieldValidator<Uint8List>? validator,
  4. Uint8List? initialValue,
  5. InputDecoration decoration = const InputDecoration(),
  6. ValueChanged<Uint8List?>? onChanged,
  7. ValueTransformer<Uint8List?>? valueTransformer,
  8. bool enabled = true,
  9. FormFieldSetter<Uint8List>? onSaved,
  10. AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  11. VoidCallback? onReset,
  12. FocusNode? focusNode,
  13. Color backgroundColor = Colors.transparent,
  14. String? clearButtonText,
  15. double? width,
  16. double height = 200,
  17. SignatureController? controller,
  18. Border? border}
)

Creates field with drawing pad on which user can doodle

Implementation

FormBuilderSignaturePad({
  Key? key,
  //From Super
  required String name,
  FormFieldValidator<Uint8List>? validator,
  Uint8List? initialValue,
  InputDecoration decoration = const InputDecoration(),
  ValueChanged<Uint8List?>? onChanged,
  ValueTransformer<Uint8List?>? valueTransformer,
  bool enabled = true,
  FormFieldSetter<Uint8List>? onSaved,
  AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  VoidCallback? onReset,
  FocusNode? focusNode,
  this.backgroundColor = Colors.transparent,
  this.clearButtonText,
  this.width,
  this.height = 200,
  this.controller,
  this.border,
}) : super(
        key: key,
        initialValue: initialValue,
        name: name,
        validator: validator,
        valueTransformer: valueTransformer,
        onChanged: onChanged,
        autovalidateMode: autovalidateMode,
        onSaved: onSaved,
        enabled: enabled,
        onReset: onReset,
        decoration: decoration,
        focusNode: focusNode,
        builder: (FormFieldState<Uint8List?> field) {
          final state = field as _FormBuilderSignaturePadState;
          final theme = Theme.of(state.context);
          final localizations = MaterialLocalizations.of(state.context);
          final cancelButtonColor =
              state.enabled ? theme.errorColor : theme.disabledColor;

          return InputDecorator(
            decoration: state.decoration,
            child: Column(
              children: <Widget>[
                Container(
                  height: height,
                  width: width,
                  decoration: BoxDecoration(
                    border: border,
                    image:
                        (null != initialValue && initialValue == state.value)
                            ? DecorationImage(
                                image: MemoryImage(state.value!),
                              )
                            : null,
                  ),
                  child: state.enabled
                      ? GestureDetector(
                          onHorizontalDragUpdate: (_) {},
                          onVerticalDragUpdate: (_) {},
                          child: Signature(
                            controller: state.effectiveController,
                            width: width,
                            height: height,
                            backgroundColor: backgroundColor,
                          ),
                        )
                      : null,
                ),
                Row(
                  children: <Widget>[
                    const Expanded(child: SizedBox()),
                    TextButton.icon(
                      onPressed: state.enabled
                          ? () {
                              state.effectiveController.clear();
                              field.didChange(null);
                            }
                          : null,
                      label: Text(
                        clearButtonText ?? localizations.cancelButtonLabel,
                        style: TextStyle(color: cancelButtonColor),
                      ),
                      icon: Icon(Icons.clear, color: cancelButtonColor),
                    ),
                  ],
                ),
              ],
            ),
          );
        },
      );