C.4. What about the basics: Borders, padding, margin, and color?

Like everything else in Flutter, these are handled with widgets. You can add padding to any widget by wrapping it in Padding:

Padding(
  padding: const EdgeInsets.all(16.0),    1
  child: Text("Wrap me up"),
),

  • 1 You can add padding around every edge this way, or use EdgeInsets.only(top: 8.0) to add padding to specific sides.

You can also add padding with a Container. The Container widget is a “convenience” widget that provides a whole slew of properties that you would otherwise get from individual widgets (like the padding widget), which solely add single properties to their children. You will likely get a lot of use out of the Container widget. It can be used to set padding, margin, background colors, borders, border-radius, width, height, box-shadows, and the list goes on.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.21.47