Scroll area
A scroll area keeps a long sequence in a bounded part of the screen. Give the region a name and enough height to show where one item ends and the next begins.
Browse the stops
#Scroll from Stop 1 to Stop 12 and back. The surrounding page stays in place while the stops move.
components/scroll-area/appliance/browse_stops.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class BrowseStops extends StatefulWidget {
const BrowseStops({super.key});
@override
State<BrowseStops> createState() => _BrowseStopsState();
}
class _BrowseStopsState extends State<BrowseStops> {
final scroll = ScrollController();
@override
void dispose() {
scroll.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 440),
child: SizedBox(
height: 150,
child: ApplianceScrollArea(
controller: scroll,
semanticLabel: 'Route stops',
child: ListView(
controller: scroll,
children: [
for (var stop = 1; stop <= 12; stop++)
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text('Stop $stop'),
),
],
),
),
),
);
}
Parameters
ApplianceScrollArea API ↗controller- Controls the scroll position. Give the child scroll view the same controller.
child- The scroll view.
axis- Which way it scrolls.
semanticLabel- Its name for a screen reader.
Shared behaviour
- Keyboard and focus. Tab into the region. Try Arrow Down, Page Down and End to reach later stops, then Home to return.
- Screen readers. Read the region’s name, then browse the stops in sequence. Scrolling brings later stops into view.
- Direction and type. The sequence keeps its top-to-bottom order in RTL. At 200% fewer stops fit before you scroll.