BoxConstraints forces an infinite width

前端 未结 3 1241
無奈伤痛
無奈伤痛 2020-12-15 16:49

I am getting an error when I add a row in column. I am getting following error:

I/flutter ( 6449): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═══════════════         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 17:10

    This happens only when you are trying to define an infinite width and height for a Row, Column or Container that is a parent of the TextField that wants to use all the space.

    To solve this, you should wrap your TextField with Flexible or Expanded.

    Do this to solve the issues above and beyond.

     Expanded(
       child: txtFirstName,
     ),
    
     Flexible(
       child: txtLastName,
     ),
    

    Full example

     Column(
        children: [
          imgHeader,
          lblSignUp,
          txtEmail,
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Expanded(
                child: txtFirstName,
              ),
              Flexible(
                child: txtLastName,
              ),
            ],
          ),
        ],
      )
    

提交回复
热议问题