我如何在颤抖的TextFormField?像这样

时间:2020-03-10 21:36:33

标签: android ios flutter mobile

TextFormField with labelText

不用担心图标,但是重要的是当TextFormField被聚焦时,轮廓边框内的 label

我不想这样:

other

2 个答案:

答案 0 :(得分:2)

如果我理解您的问题,那么您需要这样的东西:

gif-example

在这种情况下,您可以通过使用带装饰的容器和具有Text的列(当然还有TextFromField)来实现此目的,就像这样:

  Container(
   padding: EdgeInsets.all(8),
   decoration: new BoxDecoration(
     border: new Border.all(
        color: Colors.black,
        width: 1.0,
        style: BorderStyle.solid
      ),
     borderRadius: BorderRadius.circular(8.0),
   ),
   child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        Text("Label", style: TextStyle(color: Colors.black54),),
        TextFormField(
          decoration: const InputDecoration(
            suffixIcon: Icon(Icons.remove_red_eye),
            hintText: "Input text",
            // if you want to remove bottom border that changes color when field gains focus
            // then uncomment the line bellow
            // border: InputBorder.none, 
          )
        )
      ]
     )
  )

这不是最短的解决方案...但是它可以完成工作。

答案 1 :(得分:0)

您可以这样使用:

Call API_1 -> API_1 calls -> API_2