This is how to set top margin:

Set top margin in Flutter example
              Container(
                  color: Colors.blue,
                  margin: EdgeInsets.only(top: 20.0),
                  child: Text(
                    "My widget",
                  ))

In a similar way you set the bottom margin like so:

Set bottom margin in Flutter example
              Container(
                  color: Colors.blue,
                  margin: EdgeInsets.only(top: 20.0),
                  child: Text(
                    "My widget",
                  ))

To set the left or right margin simply just change top to left or right inside the EdgeInsets.only function.

Set the left margin

Set left margin in Flutter example
EdgeInsets.only(left: 20.0)

Set the right margin

Set right margin in Flutter example
EdgeInsets.only(right: 20.0)

To set margin for all sides use the .all

              Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(20.0),
                  child: Text(
                    "My widget",
                  ))

0 0 votes
Article rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments