Last updated:
0 purchases
flutter star rating
flutter_star_rating #
Flutter Star Rating widget based on Canvas.
Features #
Supports decimal numbers: 4.5, 3.4, 2.75, ...
Only display mode / Interactive mode
Customizable:
Fill color
Stroke color
Stroke width
Star Rays Count (default 5)
Empty color
Star size
Installation #
1. Depend
Add this to you package's pubspec.yaml file:
dependencies:
flutter_star_rating: ^0.0.2
copied to clipboard
2. Install
Run command:
$ flutter packages get
copied to clipboard
3. Import
Import in Dart code:
import 'package:flutter_star_rating/flutter_star_rating.dart';
copied to clipboard
Usage #
Simple display rating
StarRating(rating: 3.75),
copied to clipboard
For interactive
double rating = 0.0;
...
StarRating(
rating: rating,
onChangeRating: (int rating) {
setState(() {
this.rating = rating.toDouble();
});
},
)
copied to clipboard
Customize
StarRating(
rating: 3.0,
starConfig: StarConfig(
fillColor: Colors.red,
// other props
)
)
copied to clipboard
StarConfig - is data class, constructor params:
Name
Type
defaults
fillColor
Color
Colors.yellow
strokeColor
Color
Colors.black
strokeWidth
double
1.0
raysCount
int
5
emptyColor
Color
Colors.white
size
double
50.0
Full App Example #
import 'package:flutter/material.dart';
import 'package:flutter_star_rating/flutter_star_rating.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My App',
home: MyHomePage(title: 'Flutter Star Rating Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
double rating = 3.5;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: StarRating(
rating: rating,
onChangeRating: (int rating) {
setState(() {
this.rating = rating.toDouble();
});
},
),
),
);
}
}
copied to clipboard
TODO #
Custom Stars count
Rounded stars
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.