睡眠报告多次点击查询 显示bug
This commit is contained in:
@@ -104,7 +104,7 @@ Widget WeekDataWidget(
|
||||
displayMode: ChartDisplayMode.bar,
|
||||
barColors:
|
||||
buildWeekDatesAndPoints(sleepReport['scoreList'])['colors'],
|
||||
tips: buildValueTexts(sleepReport['scoreList']['data'], '分'.tr, 1),
|
||||
tips: buildValueTexts(sleepReport['scoreList']['data'], null, 1),
|
||||
xUnit: sleepReport['scoreList']['yUnit'],
|
||||
barWidth: 0.2,
|
||||
),
|
||||
@@ -705,16 +705,31 @@ double getYPositionBySegmentedLabels(List<double> labels, double value) {
|
||||
}
|
||||
|
||||
//关键点标签
|
||||
// List<String> buildValueTexts(
|
||||
// List<dynamic> data,
|
||||
// String unit,
|
||||
// int direction, // 0 表示左侧,1 表示右侧
|
||||
// ) {
|
||||
// if (data.isEmpty) return [];
|
||||
// return data.where((item) => item.containsKey('value')).map((item) {
|
||||
// final val = item['value'].toString();
|
||||
// return direction == 1 ? "$val$unit" : "$unit$val";
|
||||
// }).toList();
|
||||
// }
|
||||
List<String> buildValueTexts(
|
||||
List<dynamic> data,
|
||||
String unit,
|
||||
String? unit, // ✅ unit 改为可空类型
|
||||
int direction, // 0 表示左侧,1 表示右侧
|
||||
) {
|
||||
if (data.isEmpty) return [];
|
||||
|
||||
final safeUnit = unit ?? ""; // ✅ 防止 null
|
||||
|
||||
return data.where((item) => item.containsKey('value')).map((item) {
|
||||
final val = item['value'].toString();
|
||||
return direction == 1 ? "$val$unit" : "$unit$val";
|
||||
// ✅ 只有当 unit 不为空时才拼接
|
||||
if (safeUnit.isEmpty) return val;
|
||||
return direction == 1 ? "$val$safeUnit" : "$safeUnit$val";
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user