// Requires a stateful parent to manage the selected rating.
// Example: `num _ratingValue = 2;` in parent State class
RatingContainer(
name: 'rating-3',
classes: 'gap-1', // Adds spacing between the hearts
[
RatingItem(
value: 1,
isChecked: _ratingValue == 1, // Managed by parent state
onSelect: _handleSelect, // Parent updates state
style: [Mask.heart, const BgUtil('bg-red-400')],
),
RatingItem(
value: 2,
isChecked: _ratingValue == 2, // Managed by parent state
onSelect: _handleSelect, // Parent updates state
style: [Mask.heart, const BgUtil('bg-orange-400')],
),
RatingItem(
value: 3,
isChecked: _ratingValue == 3, // Managed by parent state
onSelect: _handleSelect, // Parent updates state
style: [Mask.heart, const BgUtil('bg-yellow-400')],
),
RatingItem(
value: 4,
isChecked: _ratingValue == 4, // Managed by parent state
onSelect: _handleSelect, // Parent updates state
style: [Mask.heart, const BgUtil('bg-lime-400')],
),
RatingItem(
value: 5,
isChecked: _ratingValue == 5, // Managed by parent state
onSelect: _handleSelect, // Parent updates state
style: [Mask.heart, const BgUtil('bg-green-400')],
),
],
)