A simple star rating compnent
In the pubspec.yaml
of your flutter project, add the following dependency:
dependencies:
rate: ^0.0.1
Import it:
import 'package:rate/rate.dart';
const Rate()
Rate(
iconSize: 40,
color: Colors.green,
allowHalf: true,
allowClear: true,
initialValue: 3.5,
readOnly: false,
onChange: (value) => print(value),
),
Rate(iconBuilder: _customIconBuilder),
Icon _customIconBuilder(double value, int index) {
var icon =
value > index.toDouble() ? Icons.favorite : Icons.favorite_border;
return Icon(icon, color: Colors.red);
}