1

嘿,我希望标签文本位于 的顶部边框下方onFocusedBorderTextFormField而不是顶部边框之间。我怎样才能做到这一点?嘿,我希望标签文本位于 的顶部边框下方onFocusedBorderTextFormField而不是顶部边框之间。我怎样才能做到这一点?

下面是代码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),
                ),
              ),
            ),
          ),
        ),
      ),
4

1 回答 1

0

只需将 labelText 和 labelStyle 替换为 hintText 和 hintStyle。

它向上移动的原因是因为 labelText 保持不变,它使您在新行上键入。

于 2020-07-23T21:46:13.930 回答