Flutter — Widget Padding (ENG)

Houssene Dao
Flutter Côte D'Ivoire
2 min readMay 29, 2019

Flutter is really exciting as a Framework, but getting started can be difficult if you don’t know how to use the different widgets. Today I invite you to discover the Widget Padding

For web developers, the word padding necessarily evokes something and yes, we are really talking about padding, the filling gap on all four sides of an element.

In Flutter some Widget does not allow us to create spacing, this widget solves this kind of problem. Let’s take a case, for example with the Widget Text.

Code implemented below

In our example our text has no spacing. Now we will try to add a spacing of about 16 pixels on each side. First we will declare the Padding Widget and then use the child and padding properties

Code below, the padding property allows to define the size of the spacings and child to define the widget that must have spacings in this example it is the Widget Text.

Let’s go further in our example in this case we will only add a space between the navigation bar and our text.

In this case, we will use the EdgeInsets class and mainly the only method of the latter, the only method takes as parameter the different directions left, right, top and bottom.

Now if you use a Widget that doesn’t have a padding property you know what to do. I hope you find this ticket useful.

Article en Français disponible ici.

--

--