| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- // 新人流程步骤进度条
- class StepProgressBar extends StatelessWidget {
- final int currentStep;
- final int totalSteps;
- final Color backgroundColor;
- final Color activeColor;
- final double height;
- const StepProgressBar({
- super.key,
- required this.currentStep,
- required this.totalSteps,
- this.backgroundColor = const Color(0x198A54FD),
- this.activeColor = const Color(0xFFA084FF),
- this.height = 8.0,
- }) : assert(totalSteps > 0, 'totalSteps must be greater than 0');
- @override
- Widget build(BuildContext context) {
- return Container(
- height: height,
- padding: EdgeInsets.symmetric(horizontal: 2.w, vertical: 2.w),
- decoration: ShapeDecoration(
- color: backgroundColor,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(5.r),
- ),
- ),
- child: Row(
- children: List.generate(totalSteps, (index) {
- final isStepCompleted = index < currentStep;
- return Expanded(
- child: Container(
- // margin: EdgeInsets.symmetric(horizontal: 1.w), //
- decoration: ShapeDecoration(
- color: isStepCompleted ? activeColor : Colors.transparent,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(3.r),
- ),
- ),
- ),
- );
- }),
- ),
- );
- }
- }
|