Search code examples
flutterflutter-layout

Position widget full width


I have a Positioned widget that I need to make it full width of the parent container

Widget tree is like this

Expanded
  Stack
    SomeOtherWidgets
    Positioned(
      left: 0,
      bottom: 0,
      height: 11,
      child: Container(
        // box decoration for this container
      )
    )

So what I need is a widget placed at the bottom of the Stack that goes on top of everything else in the Stack, that takes up the width of the ancestor Expanded

Is this possible? Thank you


Solution

  • You need to set left and right to 0, so it will expand full width.

    If you want to expand a Positioned widget height and width, you can use Positioned.fill() which will set left/right/top/bottom to 0. (but you can override them if needed)