semanticFormatterCallback property

SemanticFormatterCallback? semanticFormatterCallback
final

The callback used to create a semantic value from a slider value.

Defaults to formatting values as a percentage.

This is used by accessibility frameworks like TalkBack on Android to inform users what the currently selected value is with more context.

In the example below, a slider for currency values is configured to announce a value with a currency label.
link
Slider(
  value: _dollars.toDouble(),
  min: 20.0,
  max: 330.0,
  label: '$_dollars dollars',
  onChanged: (double newValue) {
    setState(() {
      _dollars = newValue.round();
    });
  },
  semanticFormatterCallback: (double newValue) {
    return '${newValue.round()} dollars';
  }
 )

Ignored if this slider is created with Slider.adaptive

Implementation

final SemanticFormatterCallback? semanticFormatterCallback;