在Flutter的ListView的动态TextField中键入值时,列表滚动

时间:2019-05-07 04:51:40

标签: android dart flutter

在将文本输入到文本字段中时,屏幕正在滚动,并且我在resizeToAvoidBottomPadding:false,中使用了此Scaffold以避免调整屏幕大小,并且“列表是带有文本字段的动态”。编辑动态textfield时如何停止滚动或调整屏幕大小?

enter image description here

我还通过在ListView.builder中添加physics: const NeverScrollableScrollPhysics()来抵抗物理滚动。

Container dynamciContainer(BuildContext context,double width,double height){
    return Container(
      child: ListView.builder
        (
          itemCount:sfieldList.length,
          shrinkWrap: true,
          padding: EdgeInsets.all(0),
          physics: const NeverScrollableScrollPhysics(),
          itemBuilder: (BuildContext ctxt, int index) {
          return dynamicItem(ctxt,width, height,sfieldList[index],index);
          }
      ),
    );
  }

TextField项

 Container textFieldContainer(double width,Fieldlist field,int p){
    return Container(

      decoration: new BoxDecoration(
          color: Colors.white,
          border: Border.all(color: Colors.grey[200], width: 2.0),
          borderRadius: new BorderRadius.all(Radius.circular(45.0))),
         padding:EdgeInsets.only(top:width*0.009,bottom: width*0.009,left: width*0.05,right: width*0.00),
         child:  new TextField(
        style: TextStyle(fontFamily: 'semibold',color: MyColors.colorPrimary),
        keyboardType:field.type=='STR'||field.type=='EMAIL'? TextInputType.text:TextInputType.number,
        textInputAction: TextInputAction.done,
        decoration: InputDecoration(contentPadding:EdgeInsets.all(8.0),hintStyle: TextStyle(fontFamily: 'semibold',color: MyColors.colorPrimary), border: InputBorder.none),
        onChanged: (String val) {
          enteredValue(field,val);
          setState(() {
            sfieldList[p].fieldvalue=val;
          });
        },),
    );
  }

0 个答案:

没有答案