Search code examples
flutterdartratingbar

Flutter : How to implement rating bar without rating action


I have some products and each one has his rating value ( like 4.2 , 4 , 3.5 , etc) and I want to display this values with rating bar like that

enter image description here

and this is my code for this part

Align(
 alignment:Alignment.topLeft,
  child:SmoothStarRating(
    allowHalfRating:false,
     starCount:5,
     rating: adminAcceptStatusAdd[index]['rate'].toDouble(),
     size: 20.0,
     isReadOnly:false,
     color: Colors.yellow,
     borderColor:Colors.yellow,
     filledIconData:Icons.star,
     halfFilledIconData:Icons.star_half,
     defaultIconData:Icons.star_border,
     spacing: .5,
     ),
     )

now I have two problem first one the rating bar allowing the user to change value rate so I want to make it just for showing and the second problem i can't convert the value from api from string to double value I'm trying

adminAcceptStatusAdd[index]['rate'].toDouble()

but it didn't work so can anyone help me please !


Solution

  • For parse double from string:

    double.parse(adminAcceptStatusAdd[index]['rate'])