flutter 抖动:文本被文本字段输入修饰遮盖

vuktfyat  于 2022-11-17  发布在  Flutter
关注(0)|答案(1)|浏览(128)

我正在创建一个多行文本字段,但是由于某种原因,我的文本被输入修饰所阻挡。它本来是单行的,但是多行破坏了它。我的代码看起来像这样:

TextField(
                                        style: Theme.of(context)
                                            .textTheme
                                            .headline4,
                                        onChanged: (value) {
                                          if (value != '') {
                                            setState(() {
                                              hasText = true;
                                            });
                                          } else {
                                            setState(() {
                                              hasText = false;
                                            });
                                          }
                                        },
                                        onSubmitted: (value) {
                                          //clear the text controller and the image and un focus the text field and set is typing to false
                                          _textEditingController.clear();

                                          _focusNode.unfocus();
                                          setState(() {
                                            isTyping = false;
                                            _image = null;
                                          });
                                        },
                                        

                                        //allow the text to be multiline
                                        
                                        keyboardType: TextInputType.multiline,
                                        maxLines: null,
                                        focusNode: _focusNode,
                                        controller: _textEditingController,
                                        decoration: InputDecoration(
                                            filled: true,
                                            //circular border
                                            border: OutlineInputBorder(

                                                //no border
                                                borderSide: BorderSide.none,
                                                borderRadius:
                                                    BorderRadius.circular(25)),
                                            //light grey color
                                            fillColor: Color(0xffF2F2F2),
                                            hintText:
                                                'Reply to ${widget.waveTile.poster.handle}'),
                                        onTap: () {
                                          setState(() {
                                            isTyping = true;
                                          });
                                        },
                                      ),

文本如下所示:

知道这是怎么回事吗?
谢谢你!

yhqotfr8

yhqotfr81#

这是因为装饰中的内容填充,请尝试将其更改为更小的值,或者为水平和垂直填充设置不同的值

contentPadding: const EdgeInsets.all(16),

相关问题