wrapWithPadding function

List<Widget> wrapWithPadding(
  1. BaseNode node,
  2. List<Widget> children, {
  3. required AlignmentModel stackAlignment,
  4. bool applyPadding = true,
})

Implementation

List<Widget> wrapWithPadding(
  BaseNode node,
  List<Widget> children, {
  required AlignmentModel stackAlignment,
  bool applyPadding = true,
}) {
  if (children.isEmpty || !applyPadding) return children;

  final EdgeInsets resolvedPadding =
      node.innerBoxLocal.edgeInsets.flutterEdgeInsets;

  if (resolvedPadding == EdgeInsets.zero) {
    return children;
  }

  return [
    // This adaptive box forces the Stack to respect the configurations of its
    // associated [node]. Without it, the Stack can produce cases where it
    // wraps around its concrete child tightly instead of expanding from a
    // SizeFit.expand.
    AdaptiveNodeBox(
      node: node,
      child: Padding(
        padding: resolvedPadding,
        child: Stack(
          clipBehavior: Clip.none,
          alignment:
              stackAlignment.flutterAlignment ?? AlignmentDirectional.topStart,
          children: children,
        ),
      ),
    ),
  ];
}