搜尋套件、儲存庫與 APP 分類

flutter_rating_bar 封面
套件詳情v4.0.1

flutter_rating_bar

一個簡單但完全可自訂的 Flutter 評分條,還包含評分條指示器,支援任意分數的評分。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
35.5萬
喜歡數
2530
Pub 分數
150

安裝套件

flutter pub add flutter_rating_bar

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個高度可自訂的Flutter評分條組件,支援分數評級,非常適合使用者反饋。它提供互動式評分條與靜態指示器,讓您能在所有平台精確控制外觀與行為。此套件輕巧易於整合,並在選擇評分時提供順暢的視覺回饋。非常適合用於評論、應用程式評分,或任何需要直覺性星號評分輸入的情境。

適用情境

  • 用戶評論系統
  • 產品評分介面
  • 反饋收集表單
  • 基於星星的評估工具
  • 互動式使用者介面元素

主要特色

  • 支援小數評分
  • 完全可自定義的外觀
  • 互動模式和非互動模式
  • 跨平台相容性
  • 與 Flutter 的簡單整合
  • 內建評分指示器

適合對象

  • 應用開發者需要反饋組件
  • 希望擁有靈活 UI 組件的設計師
  • 需要基於星號輸入的項目
  • 行動和網路應用
  • 教育或評論導向的應用程式

使用建議

  • 需要手動處理評分變更回調
  • 有限的內建驗證
  • 自定樣式可能需要額外的程式碼
  • 未針對超大資料集進行優化
  • 預設情況下沒有內建動畫

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

FLUTTER RATING BAR

Pub License Web Demo 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

Salient Features

  • Set minimum and maximum rating
  • Any widgets can be used as as rating bar/indicator items
  • Different widgets can be used in same rating bar as per position
  • Supports vertical layout
  • Glows on interaction
  • Supports RTL mode
Web Demo

Usage

Using Flutter Rating Bar

Rating Bar can be used in three ways.

First Way:

Using RatingBar.builder()

First Way

RatingBar.builder(
   initialRating: 3,
   minRating: 1,
   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 RatingBar()

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 RatingBar.builder() with index

Third Way

RatingBar.builder(
    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) 2021 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.

所屬分類

原始碼儲存庫

使用此套件的專案