Im trying to show a star icon and when user press on its it shows 5 stars so user can vote . but im getting an error that says
he following assertion was thrown while applying parent data.:
Incorrect use of ParentDataWidget.
The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type ParentData.
Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically, Expanded widgets are placed directly inside Flex widgets.
The offending Expanded is currently placed inside a Listener widget.
The ownership chain for the RenderObject that received the incompatible parent data was:
Column ← Expanded ← Container ← Listener ← RawGestureDetector ← GestureDetector ← Semantics ← _RawMouseRegion ← MouseRegion ← Semantics ← ⋯
════════ Exception caught by rendering library ═════════════════════════════════
A RenderFlex overflowed by 74 pixels on the right.
The relevant error-causing widget was
Row
lib/rating.dart/ratingbar.dart:42
i marked in the code where the error is hope anyone can help if you need more information please lave a comment . the error is online there when im pressing on the on the icon and the 5 stars with the text 'clear' is showing. I call the widget in another class if you need that also please leave a comment,
class Ratingpage extends StatefulWidget {
final int maximumRating;
final Function(int) onRatingSelected;
Ratingpage(this.onRatingSelected, [this.maximumRating = 5]);
@override
_RatingpageState createState() => _RatingpageState();
}
class _RatingpageState extends State<Ratingpage> {
int _currentRating = 0;
Widget _buildRatingStar(int index) {
if (index < _currentRating) {
return Icon(
Icons.star,
color: Colors.yellow,
);
} else {
return Icon(
Icons.star,
color: Colors.white,
);
}
}
Widget _buildBody() {
final stars = List<Widget>.generate(this.widget.maximumRating, (index) {
return GestureDetector(
child: _buildRatingStar(index),
onTap: () {
setState(() {
_currentRating = index + 1;
});
this.widget.onRatingSelected(_currentRating);
},
);
});
return
Row(here the erroroororoororoorororoororoororororoorororoorororooror
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
children: stars,
),
TextButton(
onPressed: () {
setState(() {
_currentRating = 0;
});
this.widget.onRatingSelected(_currentRating);
},
child: Text(
"Clear",
style: TextStyle(color: Colors.white),
),
),
],
);
}
@override
Widget build(BuildContext context) {
return _buildBody();
}
}
I tried to wrap with expanded but not helped. maybe anyone can help