Flutter Widgets 16 | Stepper

NieBin
flutteropen
Published in
3 min readJan 31, 2019

In this tutorial, you will learn how to use the Stepper in the flutter.

Before Start

We should create a page to contain our code.

It shows an empty page with a title.

Simple Use

When I write this article, I have used some steps to describe our tutorials. In this situation, we can use a stepper to implement this.

It will show as follows.

Constructor

Let’s look at its constructor. The steps is a list, onStepTapped, onStepContinue, onStepCancel,controlsBuilder are functions. The currentStep is the int. The type is the enum. I will tell the detail of them one by one.

steps

Let’s look at the definition of the steps.

Its constructor is below.

The title, subtitle, content are the widgets, the state is an enum. So let’s see an example.

It will show you like this.

type

It has two types, the default value is the vertical. We use the horizontal in this example.

It shows as follows.

onStepTapped&currentStep

In the fore example, when we click the second title, it doesn’t show the content of the second. We need some handle.

When you click the third title, it will show as follows.

When you click the continue or cancel, it will print as follows.

controlsBuilder

If you want to custom your own continue, cancel button, you can use the controlsBuilder to define them. The function is the same as the above. But this time, I will hide these two buttons.

It will hide these two buttons.

Conclusion

Today, we have learned the Stepper. It has many parameters, the most thing you should know that this widget is a very special widget. You can use them in the needed time.

Thanks for your reading.

The End.

The whole code in Github: https://github.com/FlutterOpen/ebook

--

--