简体   繁体   English

如何在 Flutter 上的键盘上堆叠 cursor 文本字段?

[英]How to stack cursor textfield over keyboard on Flutter?

How to solve this error?, i want to stack cursor tetxfield over keyboard.如何解决这个错误?,我想在键盘上堆叠 cursor tetxfield。

Actually result实际结果

I want the result like this我想要这样的结果

I tried used stack widget but it's not work.我尝试过使用堆栈小部件,但它不起作用。

My source Code我的源代码

Stack(
        children: [
          const Positioned.fill(
            child: Image(
              image: AssetImage('assets/images/background.png'),
              repeat: ImageRepeat.repeat,
            ),
          ),
          ListView.separated(
            itemBuilder: (_, index) => const SizedBox(),
            separatorBuilder: (_, __) => const SizedBox(
              height: 8,
            ),
            itemCount: 5,
            reverse: true,
          ),
          Positioned(
            bottom: MediaQuery.of(context).viewInsets.bottom,
            left: 0,
            right: 0,
            child: Container(
              decoration: BoxDecoration(
                color: context.theme.colorScheme.surface,
              ),
              child: Row(
                children: [
                  IconButton(
                    onPressed: () {},
                    icon: const Icon(
                      Icons.attachment_rounded,
                      color: kIconKeyboardChatColor,
                    ),
                  ),
                  const Expanded(
                    child: TextField(
                      decoration: InputDecoration(
                        enabledBorder: InputBorder.none,
                        focusedBorder: InputBorder.none,
                        hintText: 'Write a message...',
                      ),
                      keyboardType: TextInputType.multiline,
                      textInputAction: TextInputAction.newline,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      )

is other solution?是其他解决方案吗? I really appreciate your answer.我真的很感谢你的回答。

Try to add maxLines 6 and minLines 1.尝试添加 maxLines 6 和 minLines 1。

TextField(
   decoration: InputDecoration(
   enabledBorder: InputBorder.none,
   focusedBorder: InputBorder.none,
   hintText: 'Write a message...',
   textCapitalization: TextCapitalization.sentences,
   maxLines: 6,
   minLines: 1,
                      )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM