在 Flutter 中创建带圆角且没有 ActivationIndicator 的 TextFormField

Tai*_*aio 3 flutter flutter-layout

我正在尝试为看起来像的代码实现用户输入 在此处输入图片说明

目前,我只有一个容器,其中包含一行,其中包含 4 个容器,每个容器包含一个 TextFormField。我如何实现上述目标

   Padding(
     padding: const EdgeInsets.all(8.0),
         child: new Form(
            child: Container(
               color: Colors.blue[100],
               height: 100.0,
               width: 350.0,
               child: Row(
                  mainAxisAlignment:
                      MainAxisAlignment.spaceEvenly,
                      children: <Widget>[
                        Container(
                         color: Colors.amber,
                         height: 50.0,
                         width: 50.0,
                         child: TextFormField(),
                          ),

                          Container(
                            color: Colors.amber,
                            height: 50.0,
                            width: 50.0,
                            child: TextFormField(),
                             ),
                           Container(
                           color: Colors.amber,
                           height: 50.0,
                           width: 50.0,
                            child: TextFormField(),
                            ),
                            Container(
                           color: Colors.amber,
                           height: 50.0,
                           width: 50.0,
                            child: TextFormField(),
                            ),

                      ),
                                  ],
Run Code Online (Sandbox Code Playgroud)

Rao*_*che 14

我创建了这个小例子,我认为这将帮助你实现同样的想法。并回顾一下:

  • 您需要TextField使用FoucusNode
  • 您可以从装饰属性更改边框和其他装饰设置,但是如果您想更改颜色之类的东西,使用Theme小部件并从那里更改主题 总是好的
  • 如果你想阻止用户输入更多然后一个租船人使用 LengthLimitingTextInputFormatter
  • 您也可以从装饰中获得圆角和特定的边界半径

    decoration: InputDecoration(
        contentPadding: const EdgeInsets.all(8.0),
        border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(5.0),
        ),
        hintText: "0",
    ),
    
    Run Code Online (Sandbox Code Playgroud)