How do I stretch a container in flutter so that it occupies the remaining screen?

270

Wrap your bottom widget in Column inside Expanded (I think, this is what you want)

Share:
270
Rajdeep
Author by

Rajdeep

Updated on December 11, 2022

Comments

  • Rajdeep
    Rajdeep over 1 year

    I'm trying to maximize the screen as there is an unused white gap at the bottom (below the green bar which is the countdown/timer for the qn) :

    enter image description here

    Code:

        final quizBottomContentText = Container(
          width: MediaQuery.of(context).size.width,
          padding: EdgeInsets.only(left:30.0, right:30.0, top: 30.0, bottom: 30),
          child: Text(
            questions[questionNum].title,
            style: TextStyle(fontSize: 18.0),
          )
        );
    
        final quizOptions = Container(
          width: MediaQuery.of(context).size.width,
          padding: EdgeInsets.only(left: 40.0, right:40.0, bottom: 40.0),
          child: Center(
            child: Column(
                      children: questions[questionNum].options.map<Widget>(
                        (option) =>  SimpleRoundButton(
                            backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
                            buttonText: Text(option, 
                                style: TextStyle(
                                    color: Colors.white
                                ),
                            ),
                            textColor: Colors.white,
                            onPressed: (){},
                        ),
                  ).toList(),
            )
          )
        );
    
        final countdown = CountdownWidget(
              width: MediaQuery.of(context).size.width,
              duration: 20,
              triviaState: triviaState,
            );
    
        final quizBottomContent = Container(
         width: MediaQuery.of(context).size.width,
          child: Column(
            children: <Widget>[quizBottomContentText, quizOptions, countdown], // need countdown 
          ),
        ); 
    

    I've been trying the following but I cant seem to get what I want:

     // Column for quizBottomContent
     mainAxisAlignment: MainAxisAlignment.spaceBetween,