This website will be permanently discontinued and will no longer be accessible.
FINAL DAY OF SERVICE: 26 November 2024
Thank You for Your Support
Dear valued users,
We want to inform you that this website will be permanently shutting down. After this date, all services and content will no longer be accessible.
We sincerely thank you for your support and trust throughout our journey.
Important Dates:
Last Day: 26/11/2024
Data Access:Until the last day
Dear valued users,
We want to inform you that this website will be permanently shutting down. After this date, all services and content will no longer be accessible.
We sincerely thank you for your support and trust throughout our journey. Important Dates: Last Day: 26/11/2024 Data Access:Until the last day
You can create a stepper in your app by following these steps:
Step 1: Create a Stateful Widget
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
//Here We create some state widgets
@override
Widget build(BuildContext context) {
return Scaffold(
body: //Here We show Stepper
);
}
}
First, we create a Stateful widget. We create some state variables for controlling the state of the Stepper.
Step 2: Create a simple Stepper
Scaffold(
body: Stepper(
steps: [
Step(
title: const Text('Step 1'),
content: Column(
children: const [
Text('This is the first step.'),
],
),
),
Step(
title: const Text('Step 2'),
content: const Text('This is the Second step.'),
),
Step(
title: const Text('Step 3'),
content: const Text('This is the Third step.'),
),
],
),
);
Preview:
A basic stepper is showing on the screen. But each button is inactive.
Right now Step 1 is visible but we have no way to show Step 2 or Step 3.
Stepper has a few properties:
steps
We use steps to show a list of Step widgets.
currentStep
Index of the Stepper current index. Start from 0. We can specify the index value here. Adding 1 here will expand the second step. (we create a state variable to dynamically change the index here)
onStepContinue
We can pass a function that will trigger when you click on the continue button.
onStepCancel
The function can be passed here which can be triggered when you click on the cancel button.
onStepTapped
When you click on the Step tile, this function will execute. It receives the index value of the tile that you tap.
type
Here we can specify StepperType.vertical and StepperType.horizontal to make the stepper vertical and horizontal style respectively.
controlsBuilder
This is special. Here you also pass a function that gets context and details from the framework and returns a Widget that will appear at the bottom of a step. (Use for customizing action buttons).
physics
You can specify the physics effect when your every step has many widgets and it becomes scrollable.
elevation
The horizontal stepper has elevation. double value can be used for adding elevation (shadow).
Flutter Stepper Widget Properties
Step 3: Create State and Methods For Stepper
Let’s see what we can do inside the Stateful widget.
currentStep variable
int currentStep = 0;
This variable will make sure what we should display on the screen.