mnemo_cards/lib/widgets/horizontal_progress.dart

45 lines
1.1 KiB
Dart
Raw Normal View History

2024-06-11 00:28:57 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../theme/themes.dart';
class HorizontalProgressWidget extends StatelessWidget {
final int value;
final int length;
final Color color;
2024-06-15 15:42:18 +00:00
final Color? borderColor;
final double? height;
2024-06-11 00:28:57 +00:00
2024-06-12 23:00:13 +00:00
HorizontalProgressWidget(
this.value,
this.length,
this.color, {
2024-06-15 15:42:18 +00:00
this.borderColor,
this.height,
2024-06-12 23:00:13 +00:00
});
2024-06-11 00:28:57 +00:00
@override
Widget build(BuildContext context) {
2024-06-12 23:00:13 +00:00
return Container(
2024-06-15 15:42:18 +00:00
height: height ?? 16.h,
clipBehavior: Clip.hardEdge,
2024-06-12 23:00:13 +00:00
decoration: BoxDecoration(
2024-06-11 00:28:57 +00:00
color: white,
2024-06-15 15:42:18 +00:00
border: borderColor != null ? Border.all(color: borderColor!) : null,
2024-06-12 23:00:13 +00:00
borderRadius: BorderRadius.circular(16.h),
),
child: AnimatedFractionallySizedBox(
alignment: Alignment.centerLeft,
widthFactor: length == 0 ? 0 : value.toDouble() / length,
duration: Duration(milliseconds: 600),
child: Container(
2024-06-15 15:42:18 +00:00
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.h),
color: color,
),
2024-06-11 00:28:57 +00:00
),
),
);
}
}