Closed jdar closed 1 year ago
Same problem here. The FormBuilderFormSignaturePad is go into this line: MemoryImage(state.value!), but the image will blank.
In another place, the same showable value (Uint8List) in another DecorationImage was showed, so not the value is blank.
@jdar if you can, change the code this way, it is works now. Only one condition have to change: child: (initialValue == null || initialValue != state.value) and not child: state.enabled
So, if you have initialValue this will show and not show the "Signature" widget, nbut is you don't have initialValue, the "Signature" widget will shown. If you have initialValue and you want to sign again, you must first push the clear button (will do empty the state.value), and the "Signature" widget will show immadiately.
Container(
height: height,
width: width,
decoration: BoxDecoration(
border: border,
image: (null != initialValue && initialValue == state.value)
? DecorationImage(
image: MemoryImage(state.value!),
)
: null,
),
child: (initialValue == null || initialValue != state.value)
? GestureDetector(
onHorizontalDragUpdate: (_) {},
onVerticalDragUpdate: (_) {},
child: Signature(
controller: state.effectiveController,
width: width,
height: height,
backgroundColor: backgroundColor,
),
)
: null,
),
@jdar if you can, change the code this way, it is works now. Only one condition have to change: child: (initialValue == null || initialValue != state.value) and not child: state.enabled
So, if you have initialValue this will show and not show the "Signature" widget, nbut is you don't have initialValue, the "Signature" widget will shown. If you have initialValue and you want to sign again, you must first push the clear button (will do empty the state.value), and the "Signature" widget will show immadiately.
Container( height: height, width: width, decoration: BoxDecoration( border: border, image: (null != initialValue && initialValue == state.value) ? DecorationImage( image: MemoryImage(state.value!), ) : null, ), child: (initialValue == null || initialValue != state.value) ? GestureDetector( onHorizontalDragUpdate: (_) {}, onVerticalDragUpdate: (_) {}, child: Signature( controller: state.effectiveController, width: width, height: height, backgroundColor: backgroundColor, ), ) : null, ),
This is a nice behavior to have. @fehernyul or @jdar you can create a pull request with this, will be awesome! Thanks
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Describe your question
How can I set an initialValue for FormBuilderSignaturePad field? Or, in other words... when I first load the page, I want to have a value displaying in the signature pad.
I think this is likely a misunderstaning on my part.
Expected: The Uint8List is displayed as a signature.
Actual: The field is blank.
WHAT I HAVE TRIED I am populating an initialValue Uint8List from either the form-level or field level. (deserialized from json)
Thoughts: The code below (github permalink: https://github.com/flutter-form-builder-ecosystem/form_builder_extra_fields/blob/3cf217f6553f4d46b636034d92bedac811675d0b/lib/src/fields/form_builder_signature_pad.dart#L88) ... seems to indicate that any difference between an initialValue and the current state will result in a blank pad.
Perhaps I need to somehow programmatically also populate the fieldState and trigger a didChange or something? What is intended?
VERSIONS: form_builder_extra_fields: 8.3.0 running on Android 11.