Here’s a complete Flutter widget that encapsulates the provided UI elements into a reusable widget. This widget displays a title with an amount, a progress bar, and a description of the next step.
dart
import 'package:flutter/material.dart';
class ProgressStepWidget extends StatelessWidget {
final double progressValue; // Value between 0.0 and 1.0
const ProgressStepWidget({
super.key,
required this.progressValue,
});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Title and amount
Text(
"15 000 ₽",
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
// Progress bar description
Text("Шаг 1 из 3"),
SizedBox(height: 10),
// Progress bar
LinearProgressIndicator(
value: progressValue,
backgroundColor: Colors.grey[300],
color: Colors.red,
),
SizedBox(height: 10),
// Next step description
Text("Следующий шаг: данные паспорта РФ"),
],
);
}
}
Usage Example:
To use this widget in your app, simply pass the progressValue (a double between 0.0 and 1.0) when creating the widget.
dart
ProgressStepWidget(progressValue: 0.33),
Explanation:
Title and Amount: Displays the text "15 000 ₽" with a bold style.
Progress Bar Description: Shows the current step ("Шаг 1 из 3").
Progress Bar: Uses LinearProgressIndicator to display progress. The progressValue is passed as a parameter.
Next Step Description: Indicates the next step ("Следующий шаг: данные паспорта РФ").
This widget is flexible and can be reused across your app by simply adjusting the progressValue.