leauradmin
leauradmin

Reputation: 385

Bottom overflowed by 249 pixels when I click on a form field

Here is my code  
Expanded(
    child: Container(
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.only(topLeft: Radius.circular(60),topRight: Radius.circular(60)),
                    ),
                    child: Container(
                      padding: EdgeInsets.all(20),
                      child: Column( ----->line54:26
                        children: [
                          SizedBox(height: 40.0,),
                          Container(
                            padding: EdgeInsets.all(20),
                            decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(10.0),
                              boxShadow: [
                                BoxShadow(
                                  color: Color.fromRGBO(225, 95, 27, .3),
                                  blurRadius: 20.0,
                                  offset: Offset(0,10)
                                )
                              ]
                            ),
                            child: Form(
                              child: Column(
                                children: [
                                  Container(
                                    padding: EdgeInsets.all(10),
                                    decoration: BoxDecoration(
                                        border: Border(bottom: BorderSide(color: Colors.grey.shade200))
                                    ),
                                    child: TextField(
                                      decoration: InputDecoration(
                                        hintText: "Votre nom",
                                        hintStyle: TextStyle(color: Colors.grey),
                                        border: InputBorder.none
                                      ),
                                    ),
                                  ),
                                  SizedBox(height: 10),
                                  Container(
                                    padding: EdgeInsets.all(10),
                                    decoration: BoxDecoration(
                                        border: Border(bottom: BorderSide(color: Colors.grey.shade200))
                                    ),
                                    child: TextFormField(
                                      decoration: InputDecoration(
                                        hintText: "Votre prénom"
                                      ),
                                    ),
                                  ),
                                  SizedBox(height: 10),
                                  Container(
                                    padding: EdgeInsets.all(10),
                                    decoration: BoxDecoration(
                                        border: Border(bottom: BorderSide(color: Colors.grey.shade200))
                                    ),
                                    child: TextField(
                                      decoration: InputDecoration(
                                          hintText: "Numéro client",
                                          hintStyle: TextStyle(color: Colors.grey),
                                          border: InputBorder.none
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                          SizedBox(height: 40.0),
                          Container(
                            height: 50,
                            margin: EdgeInsets.symmetric(horizontal: 50),
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(50),
                              color: Colors.green
                            ),
                            child: Center(
                              child: TextButton(
                                onPressed: (){print("gfhjk");},
                                child: Text(
                                  "Activer",
                                  style: TextStyle(fontWeight: FontWeight.bold,color: Colors.white,fontSize: 16),
                                ),
                              ),
                            )
                          )
                        ],
                      ),
                    ),
                  ),
                ),

The following assertion was thrown during layout: A RenderFlex overflowed by 249 pixels on the bottom.

The relevant error-causing widget was: Column Column:file:///xxxxxxx/lib/ecrans/auth/activation_screen.dart:54:26 The overflowing RenderFlex has an orientation of Axis.vertical. The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size. This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

The specific RenderFlex in question is: RenderFlex#1a283 relayoutBoundary=up5 OVERFLOWING ... needs compositing ... parentData: offset=Offset(20.0, 20.0) (can use size) ... constraints: BoxConstraints(0.0<=w<=371.4, h=148.1) ... size: Size(371.4, 148.1) ... direction: vertical ... mainAxisAlignment: start ... mainAxisSize: max ... crossAxisAlignment: center ... verticalDirection: down

I need help

Upvotes: 2

Views: 958

Answers (1)

Youssef Hegab
Youssef Hegab

Reputation: 81

Wrap your main container with SingleChildScrollView instead of the Expanded

SingleChildScrollView(
    child: Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
            topLeft: Radius.circular(60), topRight: Radius.circular(60)),
      ),
      child: Container(
        padding: EdgeInsets.all(20),
        child: Column(
          children: <Widget>[
            SizedBox(
              height: 40.0,
            ),
            Container(
              padding: EdgeInsets.all(20),
              decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(10.0),
                  boxShadow: [
                    BoxShadow(
                        color: Color.fromRGBO(225, 95, 27, .3),
                        blurRadius: 20.0,
                        offset: Offset(0, 10))
                  ]),
              child: Form(
                child: Column(
                  children: <Widget>[
                    Container(
                      padding: EdgeInsets.all(10),
                      decoration: BoxDecoration(
                          border: Border(
                              bottom:
                                  BorderSide(color: Colors.grey.shade200))),
                      child: TextField(
                        decoration: InputDecoration(
                            hintText: "Votre nom",
                            hintStyle: TextStyle(color: Colors.grey),
                            border: InputBorder.none),
                      ),
                    ),
                    SizedBox(height: 10),
                    Container(
                      padding: EdgeInsets.all(10),
                      decoration: BoxDecoration(
                          border: Border(
                              bottom:
                                  BorderSide(color: Colors.grey.shade200))),
                      child: TextFormField(
                        decoration:
                            InputDecoration(hintText: "Votre prénom"),
                      ),
                    ),
                    SizedBox(height: 10),
                    Container(
                      padding: EdgeInsets.all(10),
                      decoration: BoxDecoration(
                          border: Border(
                              bottom:
                                  BorderSide(color: Colors.grey.shade200))),
                      child: TextField(
                        decoration: InputDecoration(
                            hintText: "Numéro client",
                            hintStyle: TextStyle(color: Colors.grey),
                            border: InputBorder.none),
                      ),
                    ),
                  ],
                ),
              ),
            ),
            SizedBox(height: 40.0),
            Container(
                height: 50,
                margin: EdgeInsets.symmetric(horizontal: 50),
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(50),
                    color: Colors.green),
                child: Center(
                  child: TextButton(
                    onPressed: () {
                      print("gfhjk");
                    },
                    child: Text(
                      "Activer",
                      style: TextStyle(
                          fontWeight: FontWeight.bold,
                          color: Colors.white,
                          fontSize: 16),
                    ),
                  ),
                ))
          ],
        ),
      ),
    ),
  ),

enter image description here

Upvotes: 0

Related Questions