如何删除文本字段的标签?

use*_*690 8 dart flutter

想问一下是否可以去掉Flutter中文本字段左上角的标签“Label”。

在此输入图像描述

小智 37

是的,在InputDecoration中将floatingLabelBehavior设置为never。这对我有用。

decoration: InputDecoration(
    floatingLabelBehavior: FloatingLabelBehavior.never,
),
Run Code Online (Sandbox Code Playgroud)


Joh*_*Joe 3

是的,有可能吗。只需删除中的hintText和即可。labelTextInputDecoration

     decoration: InputDecoration(
         border: OutlineInputBorder(
          borderRadius: const BorderRadius.all(
           const Radius.circular(5.0),
      )),
      // hintText: Localization.of(context).accessLevel,
      // labelText: Localization.of(context).accessLevel,
   ),
Run Code Online (Sandbox Code Playgroud)