flutter_star_rating 0.0.3 copy "flutter_star_rating: ^0.0.3" to clipboard
flutter_star_rating: ^0.0.3 copied to clipboard

Flutter Star Rating widget based on Canvas.

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

2. Install

Run command:

$ flutter packages get

3. Import

Import in Dart code:

import 'package:flutter_star_rating/flutter_star_rating.dart';

Usage #

Simple display rating

StarRating(rating: 3.75),

For interactive

double rating = 0.0;
...
StarRating(
  rating: rating,
  onChangeRating: (int rating) {
    setState(() {
      this.rating = rating.toDouble();
    });
  },
)

Customize

StarRating(
  rating: 3.0,
  starConfig: StarConfig(
    fillColor: Colors.red,
    // other props
  )
)

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();
            });
          },
        ),
      ),
    );
  }
}

TODO #

  • Custom Stars count
  • Rounded stars
1
likes
20
pub points
53%
popularity

Publisher

unverified uploader

Flutter Star Rating widget based on Canvas.

Homepage

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_star_rating