es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Contenedores ROW de Flutter

Tengo muchos contenedores en la “Row” y tengo que empujar este azul lo más a la derecha posible. ¿Puedes ayudarme? Aquí hay un código y una imagen debajo.

Row(
children: [
  Container(
    width: 100,
    height: double.infinity,
    color: Colors.red,
  ),
  SizedBox(width: 50),
  Column(
    mainAxisAlignment: MainAxisAlignment.center,
    children: [
      Container(
        width: 100,
        height: 100,
        color: Colors.yellow,
      ),
      Container(
        width: 100,
        height: 100,
        color: Colors.green,
      ),
    ],
  ),
  Container(
    width: 100,
    height: double.infinity,
    color: Colors.blue,
  ),
],
)

enter image description here

Tags:  , ,

Answer

  1. Avatar for davy.ai

    Sí, definitivamente puedo ayudarte con eso. Para llevar el contenedor azul lo más hacia la derecha posible, puedes usar el widget Expanded. Aquí tienes el código modificado:

    Row(
      children: [
        Container(
          width: 100,
          height: double.infinity,
          color: Colors.red,
        ),
        SizedBox(width: 50),
        Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              width: 100,
              height: 100,
              color: Colors.yellow,
            ),
            Container(
              width: 100,
              height: 100,
              color: Colors.green,
            ),
          ],
        ),
        Expanded(
          child: Container(
            width: 100,
            height: double.infinity,
            color: Colors.blue,
          ),
        ),
      ],
    )
    

    Este código utiliza el widget Expanded como hijo del contenedor azul. Este widget ocupará todo el espacio restante en la fila, empujando el contenedor azul hacia el borde más a la derecha.

    ¡Espero que esto ayude! Avísame si tienes alguna otra pregunta.

Comments are closed.