从多行TextField移除右侧的滚动条-Flutter

时间:2019-12-04 11:10:44

标签: flutter scrollbar textfield

我在以下结构中具有TextField purchaseCommentField()

    @override
      Widget build(BuildContext context)
      {
        return GestureDetector(
          onTap: CommonUtils.endEditing(context),
          child: Container(
              width: _width,
              color: Colors.white,
              child: SingleChildScrollView(
                child: Column(
                  children: <Widget>[
                    ....
                    ...
                    Visibility(
                        visible: _additionalInfo != null,
                        child: purchaseCommentField()
                    ),
                    rowSpacer(16.0),
                    actionButton(context)
                  ],
                )
              )
          ),
        );
      }

 Widget purchaseCommentField()
  {
    return TextField(
      controller: _purchaseCommentController,
      minLines: 1,
      maxLines: null,
      keyboardType: TextInputType.multiline,
      style: new TextStyle(fontSize: 14.0),
      decoration: new InputDecoration(
        labelText: 'Additional Info',
        border: OutlineInputBorder(),
      ),
    );
  }

当我聚焦文本字段时,在该字段的右边出现了不需要的滚动条:

enter image description here

当我设置fontSize:14.0时发生此问题。当我删除该字体或将fontSize设置为16.0时,右侧将没有滚动条:

enter image description here

是否可以删除文本字段中的滚动条?

1 个答案:

答案 0 :(得分:0)

尝试使用TextFormField

                    TextFormField(
                      controller: textController,
                      validator: (value) {
                        if (value.trim().isEmpty) {
                          return _reportTypeModel.language.msgEnterDesc;
                        }
                        return null;
                      },
                      style: new TextStyle(fontSize: 14.0),
                      maxLength: 500,
                      decoration: InputDecoration(
                        labelText: _reportTypeModel.language.description,
                      ),
                      minLines: 4,
                      maxLines: 6,
                      keyboardType: TextInputType.multiline,
                      textInputAction: TextInputAction.next,
                    ),

输出:

enter image description here