Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overflowing RenderFlex has an orientation of Axis.vertical

Tags:

flutter

dart

I am not able to scroll on my form, how do I solve the scrolling problem: Code and error below.

Error from the terminal: ════════ Exception caught by rendering library ═════════════════════════════════ The following assertion was thrown during layout: A RenderFlex overflowed by 179 pixels on the bottom.

The relevant error-causing widget was Column lib\auth\signupBasicDetails.dart:254 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#d8c43 relayoutBoundary=up2 OVERFLOWING

Widget build(BuildContext context) {
return Scaffold(
  resizeToAvoidBottomInset: false,
  backgroundColor: Colors.white,
  body: Container(
    width: MediaQuery.of(context).size.width,
    //color: Colors.red,
    
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          // padding: EdgeInsets.all(10),
          padding: EdgeInsets.only(left: 20, top: 60),
          child: GestureDetector(
            onTap: () {
              if (pageController.page == 0) {
                Navigator.pop(context);
              } else {
                setState(() {
                  if (fourthPage) {
                    nextButtonText = "Next";
                    fourthPage = false;
                  } else if (thirdPage) {
                    thirdPage = false;
                  } else if (secondPage) {
                    secondPage = false;
                  }
                });
                pageController.previousPage(
                    duration: Duration(milliseconds: 200),
                    curve: Curves.easeIn);
              }
            },
            child: Icon(
              Icons.arrow_back,
            ),
          ),
        ),
        SizedBox(
          height: 0.5,
        ),
        Container(
          alignment: Alignment.topCenter,
          height: 130,
          child: Image.asset(
            'images/1.jpg',
            fit: BoxFit.contain,
          ),
        ),
        Container(
          alignment: Alignment.topCenter,
          child: Text("App",
              style: TextStyle(
                fontFamily: "Source Sans Pro Regular",
                color: Colors.black,
                fontSize: 40,
              )),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 20),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Container(
                height: 15,
                width: 15,
                decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    color: redColor,
                    border: Border.all(color:redColor)),
              ),
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 5),
                child: Text(
                  "-",
                  style: TextStyle(
                      fontFamily: "Montserrat Regular",
                      fontSize: 22,
                      color:
                          secondPage ? redColor : greyColor),
                ),
              ),
              Container(
                height: 15,
                width: 15,
                decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    color: secondPage ? redColor : Colors.white,
                    border: Border.all(
                        color: secondPage
                            ? redColor
                            : greyColor)),
              ),
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 5),
                child: Text(
                  "-",
                  style: TextStyle(
                      fontFamily: "Montserrat Regular",
                      fontSize: 22,
                      color:
                          thirdPage ? redColor : greyColor),
                ),
              ),
              Container(
                height: 15,
                width: 15,
                decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    color: thirdPage ? redColor : Colors.white,
                    border: Border.all(
                        color: thirdPage
                            ? redColor
                            : greyColor)),
              ),
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 5),
                child: Text(
                  "-",
                  style: TextStyle(
                      fontFamily: "Montserrat Regular",
                      fontSize: 22,
                      color:
                          fourthPage ? redColor : greyColor),
                ),
              ),
              Container(
                height: 15,
                width: 15,
                decoration: BoxDecoration(
                    color: fourthPage ? redColor : Colors.white,
                    shape: BoxShape.circle,
                    border: Border.all(
                        color: fourthPage
                            ? redColor
                            : greyColor)),
              ),
            ],
          ),
        ),
        SizedBox(
          height: 10,
        ),
        Container(
          height: 380,
          child: PageView(
            physics: NeverScrollableScrollPhysics(),
            controller: pageController,
            children: [
              FirstPageSignUp(),
              SecondPageSignUp(),
              ThirdPageSignUp(),
              FourthPageSignUp()
            ],
          ),
        ),
        SizedBox(
          height: 1,
        ),
        Center(
          child: FlatButton(
            color: Color(0xffD21F3C),
            onPressed: () {
              setState(() {
                if (pageController.page == 0 &&
                    _formkey1.currentState.validate()) {
                  ....
                } else if (pageController.page == 1 &&
                    _formkey2.currentState.validate()) {
                  ...
                } else if (pageController.page == 2 &&
                    _formkey3.currentState.validate()) {
                  ...
                } else if (pageController.page == 3 &&
                    _formkey4.currentState.validate()) {
                  ...
                  if (vendordropdown == "...") {
                    ...
                  } else if (vendordropdown == "...") {
                    ...
                  } else if (vendordropdown == "...") {
                    ...
                  }
                  attemptSignUp(
                      ....);
                }
              });
            },
            shape: new RoundedRectangleBorder(
                borderRadius: new BorderRadius.circular(4),
                side: BorderSide(color: Color(0xffD21F3C))),
            textColor: Colors.white,
            child: Container(
                height: 45,
                width: 200,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(
                      nextButtonText,
                      style: new TextStyle(
                          color: Colors.white,
                          fontFamily: "Montserrat SemiBold",
                          fontSize: 18),
                    ),
                    Icon(Icons.arrow_forward, color: Colors.white)
                  ],
                )),
          ),
        ),
      ],
    ),
  ),
);

} }


1 Answers

You can wrap the column with a SingleChildScrollView.

SingleChildScrollView(
    child: Column(
      ...
    ),
),
like image 107
Dhritiman Roy Avatar answered Sep 15 '25 22:09

Dhritiman Roy