fluent_ui icon indicating copy to clipboard operation
fluent_ui copied to clipboard

Add controller and callbacks to `NumberBox`

Open robkri opened this issue 1 year ago • 2 comments

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.

robkri avatar Mar 25 '25 14:03 robkri

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,

bdlukaa avatar Apr 04 '25 14:04 bdlukaa