61 lines
2.2 KiB
Dart
61 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:percent_indicator/percent_indicator.dart';
|
|
import 'package:school_asignment_app/common/utils/utils.dart';
|
|
import 'package:school_asignment_app/page/global_widget/my_text.dart';
|
|
|
|
class ProgressBar extends StatefulWidget {
|
|
late double? fontSize;
|
|
late double? lineHeight;
|
|
final String title;
|
|
final Color color;
|
|
final double percent;
|
|
final EdgeInsets padingEdg;
|
|
final EdgeInsets marginEdg;
|
|
ProgressBar({Key? key,this.fontSize,this.lineHeight,required this.title,required this.color,required this.percent,required this.marginEdg,required this.padingEdg}) : super(key: key);
|
|
|
|
@override
|
|
State<ProgressBar> createState() => _ProgressBarState();
|
|
}
|
|
|
|
class _ProgressBarState extends State<ProgressBar> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var percentStr = '${Utils.doubleToStringAsFixed(widget.percent * 100)}%';
|
|
widget.fontSize ??= 10.sp;
|
|
widget.lineHeight ??= 8.h;
|
|
return Container(
|
|
margin: widget.marginEdg,
|
|
padding: widget.padingEdg,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
if (widget.title == '总正确率:') quickText('确率', color: Colors.transparent, size: widget.fontSize),
|
|
quickText(widget.title, color: const Color(0xFF8B8B8B), size: widget.fontSize),
|
|
Expanded(
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(10.r),
|
|
),
|
|
child: LinearPercentIndicator(
|
|
padding: EdgeInsets.zero,
|
|
animation: true,
|
|
lineHeight: widget.lineHeight!,
|
|
animationDuration: 2500,
|
|
percent: widget.percent,
|
|
progressColor: widget.color,
|
|
backgroundColor: const Color(0xFFE8E8E8),
|
|
barRadius: Radius.circular(10.r),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 4.w),
|
|
// percentStr
|
|
quickText(percentStr, size: widget.fontSize, color: const Color(0xFF464646)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|