123456789101112131415161718192021222324252627282930313233343536 |
- import 'package:flutter/material.dart';
- class CustomProgressBar extends StatelessWidget {
- final double progress;
- final Color color;
- final double radius;
- const CustomProgressBar({
- Key? key,
- required this.progress,
- required this.color,
- this.radius = 0,
- }) : assert(progress >= 0 && progress <= 1, '进度值必须在 0 到 1 之间'),
- super(key: key);
- @override
- Widget build(BuildContext context) {
- return Container(
- width: double.infinity,
- height: 16,
- decoration: BoxDecoration(
- border: Border.all(color: color, width: 0.5),
- borderRadius: BorderRadius.circular(radius),
- ),
- child: ClipRRect(
- borderRadius: BorderRadius.circular(radius),
- child: LinearProgressIndicator(
- value: progress,
- backgroundColor: Colors.transparent,
- valueColor: AlwaysStoppedAnimation<Color>(color),
- ),
- ),
- );
- }
- }
|