Skip to content

Commit 8f87430

Browse files
committed
Disable user input in SignaturePad when enabled is set to false
1 parent 94bc3c0 commit 8f87430

File tree

1 file changed

+18
-40
lines changed

1 file changed

+18
-40
lines changed

lib/src/fields/form_builder_signature_pad.dart

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,26 @@ class FormBuilderSignaturePad extends FormBuilderField<Uint8List> {
7373
child: Column(
7474
children: <Widget>[
7575
Container(
76-
decoration: BoxDecoration(border: border),
77-
child: GestureDetector(
78-
onHorizontalDragUpdate: (_) {},
79-
onVerticalDragUpdate: (_) {},
80-
child: Signature(
81-
controller: state._controller,
82-
width: width,
83-
height: height,
84-
backgroundColor: backgroundColor,
76+
height: height,
77+
width: width,
78+
decoration: BoxDecoration(
79+
border: border,
80+
image: state.enabled ? null : DecorationImage(
81+
image: MemoryImage(state.value),
8582
),
8683
),
84+
child: state.enabled
85+
? GestureDetector(
86+
onHorizontalDragUpdate: (_) {},
87+
onVerticalDragUpdate: (_) {},
88+
child: Signature(
89+
controller: state._controller,
90+
width: width,
91+
height: height,
92+
backgroundColor: backgroundColor,
93+
),
94+
)
95+
: null,
8796
),
8897
Row(
8998
children: <Widget>[
@@ -145,35 +154,4 @@ class _FormBuilderSignaturePadState
145154
_controller?.clear();
146155
super.reset();
147156
}
148-
149-
/*@override
150-
void didUpdateWidget(FormBuilderSignaturePad oldWidget) {
151-
print("Widget did update...");
152-
super.didUpdateWidget(oldWidget);
153-
if (widget.controller != oldWidget.controller) {
154-
oldWidget.controller?.removeListener(_handleControllerChanged);
155-
widget.controller?.addListener(_handleControllerChanged);
156-
157-
if (oldWidget.controller != null && widget.controller == null) {
158-
_controller = SignatureController(points: oldWidget.controller.value);
159-
}
160-
if (widget.controller != null) {
161-
setValue(widget.controller.value);
162-
if (oldWidget.controller == null) _controller = null;
163-
}
164-
}
165-
}
166-
167-
void _handleControllerChanged() {
168-
// Suppress changes that originated from within this class.
169-
//
170-
// In the case where a controller has been passed in to this widget, we
171-
// register this change listener. In these cases, we'll also receive change
172-
// notifications for changes originating from within this class -- for
173-
// example, the reset() method. In such cases, the FormField value will
174-
// already have been set.
175-
if (signatureController.value != value) {
176-
didChange(signatureController.value);
177-
}
178-
}*/
179157
}

0 commit comments

Comments
 (0)