Skip to content

Commit

Permalink
renamed constructor parameters
Browse files Browse the repository at this point in the history
example updated
  • Loading branch information
thangmam committed Dec 26, 2019
1 parent c8f5e2b commit 8095795
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
8 changes: 5 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ class _MyAppState extends State<MyApp> {
body: Center(
child: SmoothStarRating(
rating: rating,
size: 45,
fullRatedIconData: Icons.blur_off,
halfRatedIconData: Icons.blur_on,
size: 65,
filledIconData: Icons.star,
halfFilledIconData: Icons.star_half,
defaultIconData: Icons.star_border,
starCount: 5,
allowHalfRating: false,
spacing: 2.0,
onRatingChanged: (value) {
setState(() {
Expand Down
17 changes: 10 additions & 7 deletions lib/smooth_star_rating.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ class SmoothStarRating extends StatelessWidget {
final Color borderColor;
final double size;
final bool allowHalfRating;
final IconData fullRatedIconData;
final IconData halfRatedIconData;
final IconData filledIconData;
final IconData halfFilledIconData;
final IconData
defaultIconData; //this is needed only when having fullRatedIconData && halfRatedIconData
final double spacing;
SmoothStarRating({
this.starCount = 5,
this.spacing,
this.rating = 0.0,
this.defaultIconData,
this.onRatingChanged,
this.color,
this.borderColor,
this.size = 25,
this.fullRatedIconData,
this.halfRatedIconData,
this.filledIconData,
this.halfFilledIconData,
this.allowHalfRating = true,
}) {
assert(this.rating != null);
Expand All @@ -35,20 +38,20 @@ class SmoothStarRating extends StatelessWidget {
Icon icon;
if (index >= rating) {
icon = new Icon(
fullRatedIconData != null ? fullRatedIconData : Icons.star_border,
defaultIconData != null ? defaultIconData : Icons.star_border,
color: borderColor ?? Theme.of(context).primaryColor,
size: size,
);
} else if (index > rating - (allowHalfRating ? 0.5 : 1.0) &&
index < rating) {
icon = new Icon(
halfRatedIconData != null ? halfRatedIconData : Icons.star_half,
halfFilledIconData != null ? halfFilledIconData : Icons.star_half,
color: color ?? Theme.of(context).primaryColor,
size: size,
);
} else {
icon = new Icon(
fullRatedIconData != null ? fullRatedIconData : Icons.star,
filledIconData != null ? filledIconData : Icons.star,
color: color ?? Theme.of(context).primaryColor,
size: size,
);
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: smooth_star_rating
description: A smooth rating bar
version: 1.0.4
author: Thangmam <[email protected]>
homepage: https://github.com/thangmam/smoothratingbar.git

environment:
Expand Down

0 comments on commit 8095795

Please sign in to comment.