嘿,我希望标签文本位于onFocusedBorder
的顶部边框TextFormField
下方,而不是位于顶部边框之间。我该如何实现?
嘿,我希望标签文本位于onFocusedBorder
的顶部边框TextFormField
下方,而不是位于顶部边框之间。我该如何实现?
下面是TextFormFeild
下面是TextFormFeild
Theme(
data: Theme.of(context).copyWith(primaryColor: Colors.black),
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(33)),
child: Container(
color: Colors.white,
height: deviceSize
.height, // Ignore this
child: TextFormField(
style: TextStyle(color: Colors.black), // Text written color
controller: _controller,
cursorColor: Colors.black,
decoration: InputDecoration(
fillColor: Colors.black,
labelText: "What are you looking for?",
labelStyle: TextStyle(
color: Colors.black.withOpacity(0.7),
fontSize: deviceSize.height * 0.4,
),
prefixIcon: IconButton(
color: Colors.black.withOpacity(0.5),
icon: Icon(
Icons.search,
size: deviceSize.height * 0.6,
),
onPressed: () {
// Search functionality here
},
),
suffixIcon: IconButton(
color: Colors.black.withOpacity(0.8),
icon: Icon(
Icons.filter_list,
size: deviceSize.height * 0.6,
),
onPressed: () => _controller.clear(),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(33),
borderSide: BorderSide(
color: Colors.brown,
width: 0.7,
style: BorderStyle.solid),
),
),
),
),
),
),
答案 0 :(得分:0)
只需用hintText和hintStyle替换labelText和labelStyle。
它向上移动的原因是因为labelText保持不变,并且使您在新行中键入内容。