buildWithChild method
A build method that receives an extra child
parameter.
This method may be called with a child
different from the parameter
passed to the constructor of SingleChildStatelessWidget
.
It may also be called again with a different child
, without this widget
being recreated.
Implementation
@override
Widget buildWithChild(BuildContext context, Widget? child) {
final mediaQuery = MediaQuery.of(context);
return Stack(
children: [
child!,
if (showPadding)
_Padding(
label: 'padding',
color: Colors.red,
padding: mediaQuery.padding,
alignment: Alignment.topLeft,
),
if (showViewPadding)
_Padding(
label: 'viewPadding',
color: Colors.blue,
padding: mediaQuery.viewPadding,
alignment: Alignment.topRight,
),
if (showViewInsets)
_Padding(
label: 'viewInsets',
color: Colors.green,
padding: mediaQuery.viewInsets,
alignment: Alignment.center,
),
if (showSize) const _Size(),
],
);
}