我尝试根据设计设置TextField样式,但当我尝试设置填充颜色和边框颜色时,它们不会更改:

child: Container(
                    height: 30,
                    child: Padding(
                      padding: const EdgeInsets.only(left: 8.0, right: 8.0),
                      child: TextField(
                        onChanged: runSearch,
                        textAlign: TextAlign.start,
                        decoration: InputDecoration(
                            contentPadding: EdgeInsets.symmetric(horizontal: 0),
                            prefixIcon: Icon(Icons.search, color: Color(GoEngColors.mainColorActive)),
                            border: OutlineInputBorder(
                              borderSide: new BorderSide(color: Colors.transparent),
                              borderRadius: const BorderRadius.all(
                                const Radius.circular(30.0),
                              ),
                            ),
                            filled: true,
                            focusedBorder: null,
                            hintStyle: TextStyle(fontSize: 14, color: Color(GoEngColors.primaryTextColor)),
                            hintText: "Поиск",
                            fillColor: Color(GoEngColors.munsell)),
                      ),
                    ),
                  ),

实际结果flutter - Flutter TextField填充和边框颜色不会更改为灰色-LMLPHP
预期结果flutter - Flutter TextField填充和边框颜色不会更改为灰色-LMLPHP
static int munsell = 0xFF0F0F0;

如何将此颜色设置为背景并删除边框?
更新
在建议的解决方案的帮助下,我可以在正常状态下获得成功
flutter - Flutter TextField填充和边框颜色不会更改为灰色-LMLPHP
但这里有一个选择(聚焦)状态的结果:
flutter - Flutter TextField填充和边框颜色不会更改为灰色-LMLPHP
如何删除下划线并保持提示和文本在同一级别?

最佳答案

你的色码好像错了。您忘记再添加一个F

int munsell = 0xFFF0F0F0;

您还必须为您的InputDecoration
enabledBorder: OutlineInputBorder(
                  borderSide: BorderSide(color: Colors.transparent, width: 0.0),
                  borderRadius: const BorderRadius.all(const Radius.circular(30.0)),
                )

09-30 18:23
查看更多