I'm trying to run an existing code from another developer. Its showing me this weird error:
Xcode's output:
lib/ui/ActHospitalDetail.dart:171:25: Error: No named parameter with the name 'itemBuilder'.
itemBuilder: (context, _) => Icon(
^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_rating_bar-3.2.0+1/lib/src/rating_bar.dart:31:9: Context: Found this candidate, but the arguments don't match.
const RatingBar({
^^^^^^^^^
Here is the code related. The caller:
Row(
children: <Widget>[
RatingBar(
itemSize: ScreenUtil().setWidth(15),
initialRating: double.parse(provider.hospitalDetailModel.data.avgRating),
minRating: 0,
direction: Axis.horizontal,
allowHalfRating: true,
itemCount: 5,
ignoreGestures: true,
unratedColor: Color(clrGreyLight),
//itemPadding: EdgeInsets.symmetric(horizontal: 1.0),
itemBuilder: (context, _) => Icon(
Icons.star,
color: Color(clrYellow),
),
onRatingUpdate: (rating) {
print(rating);
},
),
SizedBox(width: ScreenUtil().setWidth(2),),
Text(provider.hospitalDetailModel.data.avgRating, style: TextStyle(fontSize: ScreenUtil().setSp(14), color: Color(clrYellow), fontWeight: FontWeight.bold) ,),
SizedBox(width: ScreenUtil().setWidth(1),),
RichText(
text: TextSpan(
text: "(" + provider.hospitalDetailModel.data.totalRating + " ",
style: TextStyle(fontSize: ScreenUtil().setSp(12), color: Color(clrGreyLight), fontWeight: FontWeight.bold),
children: <TextSpan>[
TextSpan(text: "${AppTranslations.of(context).text((int.parse(provider.hospitalDetailModel.data.totalRating) > 1) ? "Ratings" : "Rating")}" + ")", style: TextStyle(fontWeight: FontWeight.bold)),
]
),
),
//Text("(278 ratings)", style: TextStyle(fontSize: ScreenUtil().setSp(12), color: Color(clrGreyLight), fontWeight: FontWeight.bold) ,),
],
),
The "itemBuilder" is underlined with red and shows this suggestion when I hover over it:
The named parameter 'itemBuilder' isn't defined. (Documentation)
Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'itemBuilder'.
The constructor:
const RatingBar.builder({
/// {@template flutterRatingBar.itemBuilder}
/// Widget for each rating bar item.
/// {@endtemplate}
@required IndexedWidgetBuilder itemBuilder,
@required this.onRatingUpdate,
this.glowColor,
this.maxRating,
this.textDirection,
this.unratedColor,
this.allowHalfRating = false,
this.direction = Axis.horizontal,
this.glow = true,
this.glowRadius = 2,
this.ignoreGestures = false,
this.initialRating = 0.0,
this.itemCount = 5,
this.itemPadding = EdgeInsets.zero,
this.itemSize = 40.0,
this.minRating = 0,
this.tapOnlyMode = false,
this.updateOnDrag = false,
this.wrapAlignment = WrapAlignment.start,
}) : _itemBuilder = itemBuilder,
_ratingWidget = null;
And this kind of error is showing in many other snippets of the code, as well. The common thing between those snippets is that all of these undefined parameters (like itemBuilder) is shown to be in the super constructor.
So, is my version of flutter is not recognizing this syntax of constructor declaration or something? Because it works just fine in the previous developer's workstation.
Any thoughts or suggestions are welcomed.
Thank you