FormBuilderSignaturePad constructor

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,
  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({
  super.key,
  required super.name,
  super.validator,
  super.initialValue,
  super.decoration,
  super.onChanged,
  super.valueTransformer,
  super.enabled,
  super.onSaved,
  super.autovalidateMode,
  super.onReset,
  super.focusNode,
  this.backgroundColor = Colors.transparent,
  this.clearButtonText,
  this.width,
  this.height = 200,
  this.controller,
  this.border,
}) : super(
        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.colorScheme.error : 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),
                    ),
                  ],
                ),
              ],
            ),
          );
        },
      );