How to set margin for a Container in Flutter

0 votes

Hi Guys,

I am in Flutter. I have created one Container in the body part of my app. How can I set a margin in all directions for this Container?

Jul 29, 2020 in Others by akhtar
• 38,180 points
1,255 views

1 answer to this question.

0 votes

Hi@akhtar,

Margin property is used to set empty space around an object or Widget in Flutter. Most of the flutter widgets directly do not support margin property but using the Child Wrapping technique we can apply a margin to any widget in flutter using Container widget. I have attached one example below for your reference.

Container(
   margin: const EdgeInsets.fromLTRB(20, 100, 20, 20),
   child:
   RaisedButton(
   onPressed: () => sampleFunction(),
   child: Text(' Button in Flutter With Margin '),
   textColor: Colors.white,
   color: Colors.green,
    )
  )
answered Jul 29, 2020 by MD
• 95,240 points

Related Questions In Others

0 votes
1 answer

How to add a border in a Container in Flutter?

Hi@MD, By default, you can't see any border ...READ MORE

answered Sep 10, 2020 in Others by akhtar
• 38,180 points
1,533 views
0 votes
1 answer

How to apply zoom animation for each element of a list in angular?

Hey @Sid, do check if this link ...READ MORE

answered Jul 30, 2019 in Others by Vardhan
• 13,190 points
237 views
0 votes
1 answer

How to create a Volume Icon in Flutter App?

Hi@akhtar, You can use Icon Widget to create ...READ MORE

answered Jul 24, 2020 in Others by MD
• 95,240 points
441 views
0 votes
1 answer

How to add a border to a widget in Flutter?

Hi@akhtar, You need to add the TextField as a child to a Container that has ...READ MORE

answered Jul 24, 2020 in Others by MD
• 95,240 points
956 views
0 votes
1 answer

What is pubspec.yaml file in Flutter?

Hi@akhtar, It is the project's configuration file that ...READ MORE

answered Jul 20, 2020 in Others by MD
• 95,240 points
991 views
0 votes
1 answer

Error: No pubspec.yaml file found.

Hi@akhtar, You need to run this command from ...READ MORE

answered Jul 20, 2020 in Others by MD
• 95,240 points
3,591 views
0 votes
1 answer

How to launch an emulators from Flutter?

Hi@akhtar, Before launching emulators you should check if ...READ MORE

answered Jul 20, 2020 in Others by MD
• 95,240 points
2,091 views
0 votes
1 answer

How to create a container widget in Flutter?

Hi@akhtar, Container means a parent widget that contains ...READ MORE

answered Jul 28, 2020 in Others by MD
• 95,240 points
300 views
0 votes
1 answer

How to create a Project in Flutter?

Hi@akhtar, Flutter has an inbuilt command to create ...READ MORE

answered Jul 20, 2020 in Others by MD
• 95,240 points
181 views