Flutter padding for all widgets?
You can use Padding
, which is a very simple Widget
that just takes another Widget
as a child
and an EdgeInsets
object like the one you are already using as padding
.
This approach of "composition over inheritance" in Flutter is very intentional. You can find a recent discussion of the pros and cons on Flutter's Gitter channel.
Here is a supplemental answer that provides some code. As the accepted answer states, you can use the Padding widget. Flutter is different than Android or iOS because Padding is a widget rather than a property. (It is a property of Container, but internally it is still a widget.)
This is a Text widget wrapped with a Padding widget.
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("text"),
);
See my fuller answer here.