fluent_ui
fluent_ui copied to clipboard
Add controller and callbacks to `NumberBox`
NumberBox is quite uncomfortable to handle, as there is no controller to access the current value and having callbacks that behave differently to TextBox (see also https://github.com/bdlukaa/fluent_ui/issues/1196).
As both widgets have the same function with just the difference of containting text vs. a number, they should show the same behaviour. Meaning: NumberBox should be able to receive a controller in the constructor and offer the same callbacks that TextBox has.
You can access the text controller of the number box using a key:
final key = GlobalKey<NumberBoxState>();
NumberBox(
key: key,
...,
),
key.currentState?.controller.text = '1200';
The available callbacks:
-
NumberBox.onTextChanged->TextBox.onChanged, -
NumberBox.onEditingComplete->TextBox.onEditingComplete,