I have a TextField widget within a Form widget, and the TextField has a Tooltip widget within its decoration.
...surrounding input field redacted...
decoration: InputDecoration(
labelText: 'Date Carried Out',
suffixIcon: const Tooltip(
message: 'Tooltip message',
child: Icon(Icons.info,),
),
),
In some cases, the entire Form will be disabled (and hence it’s constituent fields) – however, I required some tooltips to remain enabled such that the user can still discover the meaning of the field data being displayed.
Is there an allowance in the flutter widgets for this? If not, can it still be achieved?
Thank you
3
Answers
The Tooltip widget itself doesn’t have an ignorePointer property. However, you can achieve a similar effect by wrapping the Tooltip widget with an IgnorePointer widget.
Here’s how you can implement it:
In this example, the
IgnorePointer
widget is used to conditionally ignore user input events on theTooltip
based on the value ofisFormDisabled
. WhenisFormDisabled
istrue
, theTooltip
will be disabled and won’t respond to user input, allowing users to still discover the meaning of the field data being displayed even when the form is disabled.Hope this approach helps you to control as your desire form in your flutter application.
I didn’t quite understand, but it seems you have a tooltip in a TextField inside a Form and you want to keep tooltips even if the form is disabled.
You can define a formKey as nullable and display the concerning tooltip following the formKey value
If making a TextField disabled completely disables its children like (prefix and suffix) Icons.
Then you can think of it out of box. by Putting a suffix icon directly above the TextField.
This ToolTip (suffix icon) will be enabled whatever the state of the text field.
Here’s the pseudo code for that:
Hope it helps you.