defaultLayoutBuilder method Null safety

Widget defaultLayoutBuilder(
  1. Widget? currentChild,
  2. List<Widget> previousChildren
)

The layout builder used as the default value of layoutBuilder.

The new child is placed in a Stack that sizes itself to match the largest of the child or a previous child. The children are centered on each other.

This is an AnimatedSwitcherLayoutBuilder function.

Implementation

static Widget defaultLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
  return Stack(
    alignment: Alignment.center,
    children: <Widget>[
      ...previousChildren,
      if (currentChild != null) currentChild,
    ],
  );
}