Range slider
A range slider sets a lower and upper bound together. It suits a filter where the distance between the two limits matters.
Choose a price range
#Adjust each end of the price filter. The readout gives the lowest and highest prices in dollars.
components/range-slider/appliance/choose_price_range.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class ChoosePriceRange extends StatefulWidget {
const ChoosePriceRange({super.key});
@override
State<ChoosePriceRange> createState() => _ChoosePriceRangeState();
}
class _ChoosePriceRangeState extends State<ChoosePriceRange> {
var prices = const DesignRangeValues(20, 60);
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 420),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceRangeSlider(
values: prices,
max: 100,
divisions: 20,
startLabel: 'Minimum price',
endLabel: 'Maximum price',
semanticFormatterCallback: (v) => '\$${v.round()}',
onChanged: (next) => setState(() => prices = next),
),
const SizedBox(height: 12),
Text('From \$${prices.start.round()} to \$${prices.end.round()}'),
],
),
);
}
Parameters
ApplianceRangeSlider API ↗values- Lower and upper prices on the track.
max- Largest allowed price.
startLabel- Names the lower price.
endLabel- Names the upper price.
semanticFormatterCallback- Announces each price in dollars.
onChanged- Receives the updated bounds.
Shared behaviour
- Keyboard and focus. Tab through the two ends and use the arrows to adjust the focused value.
- Screen readers. Inspect each adjustable end separately. The price summary gives both values together.
- Direction and type. Switch direction to compare the two ends of the track. Try larger text while the bounds are close together.