简体   繁体   English

Flutter,TextFormField最后一个字母旁边的小部件

[英]Flutter, widget next to the last letter of TextFormField

在此处输入图像描述

I want to move the box that is full of red background over there to the position of the empty box.我想把那边满是红色背景的盒子移到空盒子的position上。

In other words, I want to insert a container right next to the point where TextFormField ends.换句话说,我想在 TextFormField 结束点旁边插入一个容器。

Is this something that can be implemented in Flutter?这是可以在 Flutter 中实现的吗? Or is there no way?还是没有办法?

-- UPDATE - 更新

I actually want to add a "send" Icon to the end of the text.我实际上想在文本末尾添加一个“发送”图标。 All the examples I looked up were always going to the end of the Containers due to Rows, as shown in the photos I posted.由于行,我查找的所有示例总是到容器的末尾,如我发布的照片所示。 Since the position of the send icon will always change, depending on the length of the text, in real time, this problem feels very difficult to me.由于发送图标的position会一直变化,根据文本的长度,实时的,这个问题我感觉很难。 and also for your information, this is not Text, but TextField or TextFormField widget.并且为了您的信息,这不是文本,而是 TextField 或 TextFormField 小部件。

Unfortunately, there is no way of doing this since TextFormField accepts string only and not a widget.不幸的是,没有办法这样做,因为TextFormField只接受字符串而不接受小部件。 Also, according to material guidelines , any such widget should be at the end of the text field as a suffix such as:此外,根据材料指南,任何此类小部件都应位于文本字段的末尾作为后缀,例如:

TextField(
  controller: _controller,
  decoration: InputDecoration(
    hintText: "Enter a message",
    suffixIcon: IconButton(
      onPressed: () => _controller.clear(),
      icon: Icon(Icons.clear),
    ),
  ),
)

May I ask what is the purpose??请问是什么目的?? maybe we can help find better solution then?也许我们可以帮助找到更好的解决方案?

but if we have to then I can think of 2 ways.但如果我们必须这样做,我可以想到两种方法。

1- Include the box as a Text - For example ▀ (Alt + 223) 1- 将框包含为文本 - 例如 ▀ (Alt + 223)

var box = ▀
Text("efwewewefwewefe$box"),

2- Option 2: Wrap in a Stack widget 2- 选项 2:包装在 Stack 小部件中

Stack(
children: [
Text("efwewewefwewefe"),
Container(height:5, width:5, color: Colors.red]),

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

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