[Feature Request] addition validation callback to support custom effects
Basically i have a custom widget that makes the texfield shake when its empty this widget relies on a custom state global key in order to activate the shaking mechanism now previously with normal textfield ive been using the validator callback to check whether the field is empty and trigger the shake by using .formkey.currentstate.validate() example below. but now i cant achieve this in reactive forms cause the callback does not exist
TextFormField( controller: widget.textEditingController, validator: (value) { if (widget.useValidator) { if (value.isEmpty) { _shakeKey?.currentState?.shake(); return ""; } } return null; },
You can create validator which gets textfield global key via closure
Hi @Burnwood1911,
You can use the ReactiveStatusListenableBuilder to listen when the status of the ReactiveTextField changes (valid/invalid) and convert your Shaker widget into an Implicit animation instead of your current explicit animation.
Each time the status of the ReactiveTextField changes, the ReactiveStatusListenableBuilder trigger the build method in which you build your Shaker and pass as argument if you want it to shake or not (the ReactiveTextField is the child of your Shaker widget)
Let me know if it sounds good to you or if you have more questions.
If you don't want to covert your Shaker into an Implicit animation I believe you can still using the ReactiveStatusListenableBuilder and just trigger the shaker.shake() if the control is invalid and dirty