gradient_rounded_linear_progress_bar.dart 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import 'package:flutter/material.dart';
  2. class GradientRoundedLinearProgressBar extends StatelessWidget {
  3. final double progress;
  4. final double height;
  5. final double width;
  6. final Color backgroundColor;
  7. final List<Color> gradientColors;
  8. final double borderRadius;
  9. const GradientRoundedLinearProgressBar({
  10. super.key,
  11. required this.progress,
  12. this.height = 12.0,
  13. this.width = 220.0,
  14. this.backgroundColor = Colors.grey,
  15. required this.gradientColors,
  16. this.borderRadius = 8.0,
  17. });
  18. @override
  19. Widget build(BuildContext context) {
  20. return ClipRRect(
  21. borderRadius: BorderRadius.circular(borderRadius),
  22. child: Container(
  23. height: height,
  24. width: width,
  25. color: backgroundColor,
  26. child: Stack(
  27. children: [
  28. Container(
  29. width: progress * width,
  30. decoration: BoxDecoration(
  31. borderRadius: BorderRadius.circular(borderRadius),
  32. gradient: LinearGradient(
  33. colors: gradientColors,
  34. begin: Alignment.centerLeft,
  35. end: Alignment.centerRight,
  36. ),
  37. ),
  38. ),
  39. ],
  40. ),
  41. ),
  42. );
  43. }
  44. }