admin管理员组文章数量:1289507
This is the goal This is what i made
I can't customize properly the behaviour of the label text
Container(
width: 270,
height: 40,
decoration: BoxDecoration(
color: const Color.fromARGB(255, 243, 250, 220),
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.green),
),
child: TextFormField(
controller: _emailController,
textAlign: TextAlign.left,
decoration: const InputDecoration(
labelText: 'USERNAME OR EMAIL',
floatingLabelBehavior: FloatingLabelBehavior.auto,
floatingLabelAlignment:
FloatingLabelAlignment.start,
border: InputBorder.none,
labelStyle: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
fontWeight: FontWeight.normal,
letterSpacing: 0.4,
color: const Color.fromARGB(255, 88, 88, 88)),
contentPadding: EdgeInsets.symmetric(
horizontal: 20, vertical: 18),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your email';
}
return null;
},
),
),
Basically, I want the label text to move to the uppermost left of the textbox when i click it, so I can type the input without the label text disappearing ang obstructing the input
This is the goal This is what i made
I can't customize properly the behaviour of the label text
Container(
width: 270,
height: 40,
decoration: BoxDecoration(
color: const Color.fromARGB(255, 243, 250, 220),
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.green),
),
child: TextFormField(
controller: _emailController,
textAlign: TextAlign.left,
decoration: const InputDecoration(
labelText: 'USERNAME OR EMAIL',
floatingLabelBehavior: FloatingLabelBehavior.auto,
floatingLabelAlignment:
FloatingLabelAlignment.start,
border: InputBorder.none,
labelStyle: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
fontWeight: FontWeight.normal,
letterSpacing: 0.4,
color: const Color.fromARGB(255, 88, 88, 88)),
contentPadding: EdgeInsets.symmetric(
horizontal: 20, vertical: 18),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your email';
}
return null;
},
),
),
Basically, I want the label text to move to the uppermost left of the textbox when i click it, so I can type the input without the label text disappearing ang obstructing the input
Share Improve this question edited Feb 20 at 4:44 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges asked Feb 20 at 3:25 Cedric Gian C. CombateCedric Gian C. Combate 434 bronze badges1 Answer
Reset to default 2All you had to do was to give padding to the label property by wrapping it by Padding Widget.
Full Code : -
Container(
width: 270,
decoration: BoxDecoration(
color: const Color.fromARGB(255, 243, 250, 220),
border: Border.all(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(25)),
),
child: TextFormField(
decoration: InputDecoration(
border: InputBorder.none,
label: Padding(
padding: EdgeInsets.only(bottom: 5),
child: Text('USERNAME OR EMAIL'),
),
labelStyle: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
fontWeight: FontWeight.normal,
letterSpacing: 0.4,
color: const Color.fromARGB(255, 88, 88, 88),
),
contentPadding: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
),
),
)
Output :-
本文标签: Text form field label text behaviourflutter dartStack Overflow
版权声明:本文标题:Text form field label text behaviour - flutter dart - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741460245a2379994.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论