How do for the child widget of a Column expands to the maximum width of the parent(Column)?

Asked

Viewed 73 times

4

Form(
    child: Column(
    children: <Widget>[
    CustomTextFormField("E-mail"),
    CustomTextFormField('Senha'),
       Expanded(
          child: FittedBox(
            fit: BoxFit.fitWidth,
            child: RaisedButton(
              onPressed: () {},
              color: Colors.redAccent,
              child: Text(
                'Entrar',
                style: TextStyle(color: Colors.white),
              ),
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(50)),
            ),
          ),
        )
      ],
    ))

That’s my code, when I use the Expanded the Widget just add up. I’m following the exact example I found in flutter documentation

What am I doing wrong??

1 answer

3


Use the Expanded in the son of Column should be enough, however, you can always try to add as a property of the column: crossAxisAlignment: CrossAxisAlignment.stretch to make all the children of this occupy the full width.

The SizedBox here with BoxFit.fitWidth is not necessary to reach this end, in fact it is ambiguous bringing nothing new.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.