pargress_bar.dart 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import 'package:flutter_screenutil/flutter_screenutil.dart';
  2. import 'package:get/get.dart';
  3. import 'package:flutter/material.dart';
  4. class ProgressBar extends StatelessWidget {
  5. final String title;
  6. final RxInt value;
  7. final Color color;
  8. const ProgressBar({
  9. super.key,
  10. required this.title,
  11. required this.value,
  12. required this.color,
  13. });
  14. @override
  15. Widget build(BuildContext context) {
  16. return Obx(() {
  17. final double progress = (value.value / 100).clamp(0.0, 1.0);
  18. return Container(
  19. child: Row(
  20. children: [
  21. Text(title),
  22. SizedBox(width: 3.w),
  23. Expanded(
  24. child: Stack(
  25. children: [
  26. Container(
  27. height: 11.h,
  28. decoration: BoxDecoration(
  29. color: color.withValues(alpha: 0.3),
  30. borderRadius: BorderRadius.circular(53.r),
  31. ),
  32. ),
  33. FractionallySizedBox(
  34. widthFactor: progress,
  35. child: Container(
  36. height: 11.h,
  37. decoration: BoxDecoration(
  38. color: color,
  39. borderRadius: BorderRadius.circular(53.r),
  40. ),
  41. ),
  42. ),
  43. Positioned.fill(
  44. child: Center(
  45. child: Text(
  46. "${value.value}%",
  47. textAlign: TextAlign.center,
  48. style: TextStyle(
  49. color: Colors.white,
  50. fontSize: 7.sp,
  51. fontWeight: FontWeight.w500,
  52. shadows: [
  53. Shadow(
  54. color: Colors.black.withValues(alpha: 0.6),
  55. offset: Offset(1, 1),
  56. blurRadius: 3.r,
  57. ),
  58. ],
  59. ),
  60. ),
  61. ),
  62. ),
  63. ],
  64. ),
  65. ),
  66. ],
  67. ),
  68. );
  69. });
  70. }
  71. }