Rating
A rating records a judgment on a small, ordered scale. Name the thing being rated and show how many marks are available.
Rate a guide
#Choose a rating for the guide and read the score out of five.
Read the score out of five below the stars.
components/rating/appliance/rate_guide.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class RateGuide extends StatefulWidget {
const RateGuide({super.key});
@override
State<RateGuide> createState() => _RateGuideState();
}
class _RateGuideState extends State<RateGuide> {
int score = 3;
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceRating(
semanticLabel: 'Rate the guide',
value: score.toDouble(),
onChanged: (next) => setState(() => score = next),
),
const SizedBox(height: 12),
Text('Rated $score out of 5'),
],
);
}
Parameters
ApplianceRating API ↗value- Score currently shown by the marks.
semanticLabel- Names what the reader is rating.
onChanged- Receives the new score.
Shared behaviour
- Keyboard and focus. Focus the rating. Use the arrow keys on a slider, or activate one of the individual stars. The score stays visible after focus leaves.
- Screen readers. Inspect the name and current score, then move past the marks to the numeric result.
- Direction and type. Switch to RTL to inspect the order of the marks. The score below them follows the text scale.