Skip to content
On this page

Rate 评分

代码演示

基本用法

dart
Rate(
  count: 5,
  value: model.value,
  onChange: (v) => model.value = v,
),

自订图标

dart
Rate(
  count: 5,
  value: model.value,
  onChange: (v) => model.value = v,
  voidIcon: VanIcons.like_o,
  icon: VanIcons.like,
),

自订样式

dart
Rate(
  count: 5,
  value: model.value,
  onChange: (v) => model.value = v,
  voidIcon: const Icon(VanIcons.star, color: Color(0xFFCCCCCC)),
  icon: const Icon(VanIcons.star, color: Color(0xFFF8D44E)),
),

半星

dart
Rate(
  count: 5,
  value: model.value,
  allowHalf: true,
  onChange: (v) => model.value = v,
),

自订数量

dart
Rate(
  count: 6,
  value: model.value,
  onChange: (v) => model.value = v,
),

API

Props类型描述
valuedouble当前值
onChangeFunction(double v)值变化触发
countint最大值
sizedouble大小
voidIconWidget | Icon | String未选中图标
iconWidget | Icon | String选中图标
colorColor选中颜色
voidColorColor未选中颜色
gapdouble间距
allowHalfbool允许半星