FormBuilderSignaturePad constructor
FormBuilderSignaturePad({
- Key? key,
- 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,
- VoidCallback? onReset,
- FocusNode? focusNode,
- Color backgroundColor = Colors.transparent,
- String? clearButtonText,
- double? width,
- double height = 200,
- SignatureController? controller,
- 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),
),
],
),
],
),
);
},
);