flutter_rating_bar 3.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 99

FLUTTER RATING BAR

Pub License Download GitHub code size in bytes GitHub stars

A simple yet fully customizable rating bar for flutter which also include a rating bar indicator, supporting any fraction of rating.

DEMO

What's new in v2.x.x and up #

  • Any widgets can be used as as rating bar/indicator items
  • Different widgets can be used in same rating bar as per position
  • Introduced vertical layout
  • Glow on interaction
  • Supports RTL mode

Usage #

Using Flutter Rating Bar #

Rating Bar can be used in three ways.

First Way: #

Using itemBuilder

First Way

RatingBar(
   initialRating: 3,
   direction: Axis.horizontal,
   allowHalfRating: true,
   itemCount: 5,
   itemPadding: EdgeInsets.symmetric(horizontal: 4.0),
   itemBuilder: (context, _) => Icon(
     Icons.star,
     color: Colors.amber,
   ),
   onRatingUpdate: (rating) {
     print(rating);
   },
);
Second Way: #

Using rating widgets

Second Way

RatingBar(
   initialRating: 3,
   direction: Axis.horizontal,
   allowHalfRating: true,
   itemCount: 5,
   ratingWidget: RatingWidget(
     full: _image('assets/heart.png'),
     half: _image('assets/heart_half.png'),
     empty: _image('assets/heart_border.png'),
   ),
   itemPadding: EdgeInsets.symmetric(horizontal: 4.0),
   onRatingUpdate: (rating) {
     print(rating);
   },
);

Heart Icons are Available Here.

Third Way: #

Using item builder with index

Third Way

RatingBar(
    initialRating: 3,
    itemCount: 5,
    itemBuilder: (context, index) {
       switch (index) {
          case 0:
             return Icon(
                Icons.sentiment_very_dissatisfied,
                color: Colors.red,
             );
          case 1:
             return Icon(
                Icons.sentiment_dissatisfied,
                color: Colors.redAccent,
             );
          case 2:
             return Icon(
                Icons.sentiment_neutral,
                color: Colors.amber,
             );
          case 3:
             return Icon(
                Icons.sentiment_satisfied,
                color: Colors.lightGreen,
             );
          case 4:
              return Icon(
                Icons.sentiment_very_satisfied,
                color: Colors.green,
              );
       }
    },
    onRatingUpdate: (rating) {
      print(rating);
    },
;

Using Flutter Rating Bar Indicator #

Indicator

RatingBarIndicator(
    rating: 2.75,
    itemBuilder: (context, index) => Icon(
         Icons.star,
         color: Colors.amber,
    ),
    itemCount: 5,
    itemSize: 50.0,
    direction: Axis.vertical,
),

Vertical Mode #

Vertical

In order to make the indicator scrollable, just use 'physics' property as in the example.

Info #

To know more about the available properties, head on to api docs.

Feel Free to request any missing features or report issues here.

License #

Copyright (c) 2019 Sarbagya Dhaubanjar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3.0.0 #

Breaking Changes This version requires flutter >= 1.9.

  • Removed alpha property, as alpha vale can be provided directly with unratedColor.
  • Adjusted some default behaviours for size and unratedColor.
  • FIXED Issue while using RatingWidget in RTL mode.
  • Improved dart docs

2.0.0+2 #

  • Fixed Issue with unratedColor being null. Issue #13 & #14
  • Fixed alpha property behaving in opposite manner.

2.0.0+1 #

2.0.0 #

Breaking Changes

  • FlutterRatingBar is renamed to RatingBar and FlutterRatingBarIndicator to RatingBarIndicator.
  • itemBuilder is introduced. Now you can use any widget as items with Rating Bar.
  • Improved RTL Mode.
  • Vertical Mode.
  • Glow while rating.

1.3.0+1 #

  • FIXED Rating Indicator not switching to RTL mode.

1.3.0 #

  • FEATURE ADDED Added Support for RTL Mode Issue #5
  • FIXED Fixed issue with allowHalfRating Issue #6

1.2.0 #

1.1.0 #

  • ignoreGestures property added to FlutterRatingBar as per #1 by @Skquark.
  • tapOnlyMode property added to FlutterRatingBar.
  • Readme updated with customization images and links to api docs.

1.1.0 #

  • FlutterRatingBar is also fully customizable as Indicator now.
  • Readme updated with customization examples.
  • Dart-complaint docs added.
  • [Breaking Change] size property in FlutterRatingBar is changed to itemSize for the sake of consistency.

1.0.0 #

  • Initial release

example/README.md

flutter_rating_bar_example #

More Detailed Example

Using Flutter Rating Bar #

FlutterRatingBar(
      initialRating: 3,
      fillColor: Colors.amber,
      borderColor: Colors.amber.withAlpha(50),
      allowHalfRating: true,
      onRatingUpdate: (rating) {
           print(rating);
      },
),

Using Flutter Rating Bar Indicator #

FlutterRatingBarIndicator(
     rating: 2.75,
     itemCount: 5,
     itemSize: 50.0,
     emptyColor: Colors.amber.withAlpha(50),
),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_rating_bar: ^3.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_rating_bar/flutter_rating_bar.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
97
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
99
Learn more about scoring.

We analyzed this package on Nov 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/flutter_rating_bar.dart.

Run flutter format to format lib/flutter_rating_bar.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test