小编Nis*_*ngh的帖子

仅当我输入一些文本时,如何将标签文本移动到输入文本字段的顶部

我只想在输入一些文本时将标签文本移动到输入文本字段的顶部。当前,当输入文本字段获得焦点时,它会移动到顶部。

Widget nameField() {
    return TextFormField(
      keyboardType: TextInputType.text,
      autofocus: false,
      textAlign: TextAlign.start,
      textInputAction: TextInputAction.done,
      controller: nameTextEditingController,
      style: TextStyle(
          color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500),
      decoration: const InputDecoration(
        contentPadding: EdgeInsets.symmetric(vertical: 15),
        labelText: Strings.user_info_page_name_placeholder,
        labelStyle: TextStyle(
            color: Colors.grey, fontSize: 18, fontWeight: FontWeight.w500),
        focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.transparent, width: 1)),
      ),
    );
  }

Run Code Online (Sandbox Code Playgroud)

flutter

7
推荐指数
2
解决办法
6632
查看次数

标签 统计

flutter ×1