dart 如何调整LabelText高度?

x8goxv8g  于 2023-07-31  发布在  其他
关注(0)|答案(1)|浏览(108)

我正试图让latbeltext“电子邮件”更高,以便它可以越过边界

TextFormField(
                  decoration: InputDecoration(
                    labelStyle: TextStyle(
                      color: AppColors.pink,

                      fontSize: 24,
                       height: -0.05, // this height is not changing the position of the text 
                      fontWeight: FontWeight.bold,
                    ),
                    floatingLabelBehavior: FloatingLabelBehavior.always,
                    floatingLabelStyle: TextStyle(
                      color: AppColors.black,
                      height: -0.05,
                      fontSize: 24, // Adjust the font size as desired
                      fontWeight: FontWeight.bold,
                    ),
                    contentPadding:
                        EdgeInsets.symmetric(vertical: 15.0, horizontal: 24.0),
                  
                  

                    focusedBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(25.0),
                      borderSide: BorderSide(
                        color: AppColors.darkgrey,
                      ),
                    ),
                    //  isDense: true,

                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(25.0),
                    ),
                    hintText: 'Foulen@domaine.com',
                    labelText: "Email",
                  ),
                  
                  onSaved: (value) {
                    _email = value!;
                  },
                ),

字符串
问题是高度只在textformfield被聚焦时起作用when textfield is focusedwhen textfield is not focused我希望标签“电子邮件”即使在该字段未被聚焦时也保持在边框的顶部

bnl4lu3b

bnl4lu3b1#

你可以像这样使用TextFormField

TextField(
    decoration: InputDecoration(
      border: OutlineInputBorder(),
      labelText: 'Email',
      floatingLabelBehavior:FloatingLabelBehavior.always, 
    ),
  )

字符串

相关问题