Skip to main content

SafeArea

Avoids system UI such as notches, status bars, and navigation bars by adding padding to keep content within the safe region.

Basic Usage​

widgets.SafeArea{
Child: content,
}

Properties​

PropertyTypeDescription
TopboolInclude top inset
BottomboolInclude bottom inset
LeftboolInclude left inset
RightboolInclude right inset
Childcore.WidgetChild widget

By default (all fields false), SafeArea applies padding on all sides. Setting one or more sides to true switches to selective mode, where only the specified sides receive padding. For example, setting Top: true, Bottom: true applies padding on top and bottom only, leaving left and right unpadded.

Selective Sides​

Apply safe area padding only on specific sides:

widgets.SafeArea{
Top: true,
Bottom: true,
Child: content,
}

Common Patterns​

Full-Screen Layout with Safe Content​

func (s *myState) Build(ctx core.BuildContext) core.Widget {
return widgets.SafeArea{
Child: widgets.PaddingAll(20,
widgets.Column{
MainAxisSize: widgets.MainAxisSizeMin,
Children: []core.Widget{
header,
widgets.VSpace(16),
content,
},
},
),
}
}