Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expand column to fit screen width

Tags:

flutter

dart

So i like to figure out how to make Card widget become full width in flutter, basically it only expand its width based on its child, i want it to fit the screen, the task fairly simple but im having a really hard time achieving that, in my scaffold basically it contain two card, and have some text in it, the card only expand to the size of the end of the text, i want the card to be full width, how do i achieve this?

I expect it the card to be full width of the screen, but the card only wrap the children text widget

like image 777
Derpington Avatar asked Oct 15 '25 15:10

Derpington


2 Answers

Wrap the Column in a Container widget and set it's width to double.infinity

This way you'll save some lines of code.

Example Code:

Container(
  width : double.infinity,
  child: Column([...])
)
like image 164
Son of Stackoverflow Avatar answered Oct 18 '25 07:10

Son of Stackoverflow


Try this.

Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Container(
              width: double.infinity,
              child: new Card(child: Text("This Card is Expanded to full width"),),
            )
          ],
        )
like image 42
Shahzad Akram Avatar answered Oct 18 '25 06:10

Shahzad Akram



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!