1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] RenderBox was not laid out when using Positioned in Stack

Discussão em 'Mobile' iniciado por Stack, Novembro 7, 2024 às 09:02.

  1. Stack

    Stack Membro Participativo

    I want to position Container with two buttons wrapped in Row in my Stack widget.

    This is what I want to achieve. This text should be scrolled if it's long enough, that's why I have SingleChildScrollView. Last thing I need to do is to position this two buttons on bottom

    [​IMG]

    However, when I do that it's not working and I am getting this error: RenderBox was not laid out: RenderDecoratedBox#04ae9 relayoutBoundary=up8

    How to fix this?

    Stack(
    children: [
    SizedBox(
    height: size.width,
    child: (...)
    ),
    Container(
    margin: EdgeInsets.only(
    top: size.width - 16,
    bottom: 64,
    ),
    decoration: BoxDecoration(
    borderRadius: BorderRadius.only(
    topLeft: Radius.circular(16),
    topRight: Radius.circular(16),
    ),
    color: Colors.white
    ),
    child: MainPadding(
    child: Stack(
    children: [
    Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
    Text('Nazwa produktu'),
    Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
    NumberPicker(),
    Text('250 zł')
    ],
    ),
    const SizedBox(height: 16),
    Text('Opis'),
    const SizedBox(height: 8),
    Expanded(
    child: SingleChildScrollView(
    child: Text('...'),
    ),
    ),
    ],
    ),
    Positioned(
    bottom: 32,
    child: Container(
    decoration: BoxDecoration(
    color: Colors.white,
    border: Border.all(
    color: Colors.black
    )
    ),
    child: Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
    Expanded(
    child: ElevatedButton(
    onPressed: someMethod,
    child: Text('kup i zapłać'),
    ),
    ),
    const SizedBox(width: 8),
    Expanded(
    child: ElevatedButton(
    onPressed: someMethod2,
    child: Text('Do koszyka'),
    ),
    )
    ],
    ),
    ),
    ),
    ],
    ),
    ),
    )
    ],
    ),

    Continue reading...

Compartilhe esta Página