import 'package:flutter/material.dart'; class DotNumber extends StatelessWidget { final double number; final Color color; final int dotLength; final double size; final String prefix; final double correct; const DotNumber( this.number, { this.dotLength = 4, // 小数点后面的位数 this.color = const Color.fromRGBO(255, 255, 255, .7), // 文本颜色 this.size = 32.0, // 字符尺寸 this.prefix = '', // 前缀字符 this.correct = 0, // 小数点底部边距修正 Key? key, }) : super(key: key); @override Widget build(BuildContext context) { return Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( prefix + number.truncate().toString(), style: TextStyle( color: color, fontSize: size, ), ), Padding( padding: EdgeInsets.only( bottom: correct > 0 ? correct : (size / 10), ), child: Text( (number % 1).toStringAsFixed(dotLength).substring(1), style: TextStyle( color: color.withAlpha(0xB3), fontSize: size * 0.618, ), ), ), ], ); } }