评分对话框
一个精美且可自定义的 Flutter 星级评分对话框包。


导入 rating_dialog 包
要使用 rating_dialog 插件,请按照 插件安装说明 操作。
使用该包
将以下导入添加到您的 Dart 代码中
import 'package:rating_dialog/rating_dialog.dart';
我们使用内置的 showDialog 函数显示评分对话框
showDialog(
context: context,
barrierDismissible: true, // set to false if you want to force a rating
builder: (context) {
return RatingDialog(
icon: const FlutterLogo(
size: 100,
colors: Colors.red), // set your own image/icon widget
title: "The Rating Dialog",
description:
"Tap a star to set your rating. Add more description here if you want.",
submitButton: "SUBMIT",
alternativeButton: "Contact us instead?", // optional
positiveComment: "We are so happy to hear :)", // optional
negativeComment: "We're sad to hear :(", // optional
accentColor: Colors.red, // optional
onSubmitPressed: (int rating) {
print("onSubmitPressed: rating = $rating");
// TODO: open the app's page on Google Play / Apple App Store
},
onAlternativePressed: () {
print("onAlternativePressed: do something");
// TODO: maybe you want the user to contact you instead of rating a bad review
},
);
});