Flutter Widgets 10 | Placeholder

NieBin
flutteropen
Published in
3 min readJan 23, 2019

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

Before Start

This widget is simple, but we also need a page to contain our page, so we should create a page first.

It will show nothing, but with a title.

Simple Use

So what about the Placeholder, it is a widget to note there have some widget need to implement. So its intention is as its name, hold the place to notice people comply it again in the future. It is so simple. Let’s look at the codes.

It will show like this.

Constructor

As I often say, if you want to use a widget, you should look at its constructor first. As follows.

The parameter is so simple, we have learned the types before. Just look at its parameters one by one.

color

This parameter will set the color of the line in the Placeholder. Let’s look at an example as below.

strokeWidth

This parameter will control the width of the line in the Placeholder. The example is below.

It will show like this.

fallbackWidth & fallbackHeight

These two parameters control the width, height of the Placeholder. If you want to set Placeholder with width =100, height = 100 and just set the fallbackWidth=100, fallbackHeight = 100, it may be not fit your requirements. So you should use with the Container. Let's look at the code as follows.

It will show as follows, the second fit your requirements, but the first one doesn’t. You should care about that.

Conclusion

We have learned the simple widget, but I also suggest you code them by yourself. Only code enough, you can easy to use them.

Thanks for your reading.

The End.

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

--

--