【问题标题】:A RenderFlex overflowed by 14 pixels on the bottom. The relevant error-causing widget was AlertDialog一个 RenderFlex 在底部溢出了 14 个像素。相关的导致错误的小部件是 AlertDialog
【发布时间】:2021-09-08 04:51:44
【问题描述】:

我正在创建一个对话框,当我单击编辑图标按钮时它会打开,但是当我单击文本字段输入文本时它会向我发送此错误

════════ Exception caught by rendering library ═════════════════════════════════
A RenderFlex overflowed by 14 pixels on the bottom.
The relevant error-causing widget was
AlertDialog

这是我的对话框代码

void _getSelectedRowInfo(dynamic date,dynamic timein,dynamic timeout) {
    Widget okButton = FlatButton(  
    child: Text("Submit",style: TextStyle(fontWeight: FontWeight.bold,color: Colors.blue[500],fontSize: 20),),  
    onPressed: () { 

   
    },  
  ); 
  
    AlertDialog alert = AlertDialog( 
scrollable: true,  
    //contentPadding:EdgeInsets.fromLTRB(0, 20, 0, 20),
    insetPadding: EdgeInsets.symmetric(vertical: 150),
    //contentPadding: const EdgeInsets.all(16.0),
    title: Text("Request to change time",style: TextStyle(fontWeight: FontWeight.bold,color: Colors.blue[500])),  
    
    content:Container(child: SingleChildScrollView( 
      scrollDirection: Axis.vertical,
    child:Column(children:<Widget> [
      
      TextField(
        decoration: InputDecoration(labelText: date,hintText: "Date"),
        controller:dateController ,
      ),
      TextField(
        decoration: InputDecoration(labelText: timein,hintText: "Time in"),
        controller:timeinController ,
      ),
      TextField(
        decoration: InputDecoration(labelText:timeout,hintText: "Time out"),
        controller:timeoutController ,
      ),
      
     ]), 
  )
  ),
  actions: [  
      okButton,  
      
    ],  
  );  
      showDialog(  
    context: context,  
    builder: (BuildContext context) {  
      return alert;  
    },  
  );  
 
    
  }

这是我的对话框的样子

当点击第一个文本字段时,它看起来像这样

请帮我解决一下。

【问题讨论】:

    标签: android flutter dart popup render


    【解决方案1】:

    可以将AlertDialog的scrollable参数设置为true,避免溢出:

    AlertDialog(
      scrollable: true,
      insetPadding: EdgeInsets.symmetric(vertical: 150),
      title: Text("Request to change time",
                  style: TextStyle(
                    fontWeight: FontWeight.bold,
                    color: Colors.blue[500],)),
      content: Column(children: <Widget>[
        TextField(
          decoration: InputDecoration(labelText: date, hintText: "Date"),
          controller: dateController,
        ),
        TextField(
          decoration: InputDecoration(labelText: timein, hintText: "Time in"),
          controller: timeinController,
        ),
        TextField(
          decoration:
          InputDecoration(labelText: timeout, hintText: "Time out"),
          controller: timeoutController,
        ),
      ]),
      actions: [
        ...
      ]
    )
    

    【讨论】:

      【解决方案2】:
          AlertDialog alert = AlertDialog( 
              scrollable: true, 
              //contentPadding:EdgeInsets.fromLTRB(0, 20, 0, 20),
              insetPadding: EdgeInsets.symmetric(vertical: 150),
              //contentPadding: const EdgeInsets.all(16.0),
              title: Text("Request to change time",style: TextStyle(fontWeight: FontWeight.bold,color: Colors.blue[500])),  
              
              content:Container(child: SingleChildScrollView( 
                scrollDirection: Axis.vertical,
              child:Column(
                crossAxisAlignment: CrossAxisAlignment.spaceBetween,
                children:<Widget> [
                
                TextField(
                  decoration: InputDecoration(labelText: date,hintText: "Date"),
                  controller:dateController ,
                ),
                TextField(
                  decoration: InputDecoration(labelText: timein,hintText: "Time in"),
                  controller:timeinController ,
                ),
                TextField(
                  decoration: InputDecoration(labelText:timeout,hintText: "Time out"),
                  controller:timeoutController ,
                ),
                
               ]), 
            )
            ),
            actions: [  
                okButton,  
                
              ],  
            );  
                showDialog(  
              context: context,  
              builder: (BuildContext context) {  
                return alert;  
              },  
            );  
           
              
            }
      

      【讨论】:

      • 欢迎您。你能标记一下吗,因为这对你有用。 @TimeToCode
      猜你喜欢
      • 2021-01-31
      • 2020-04-16
      • 2021-03-03
      • 2020-10-08
      • 2021-12-24
      • 2020-02-18
      • 2021-08-27
      • 2019-05-21
      • 2021-08-04
      相关资源
      最近更新 更多