繁体   English   中英

TextFormField 边框颜色不变

[英]TextFormField Border color does not change

    TextFormField(
          decoration: InputDecoration(
            labelText: 'Ürün',
            labelStyle: TextStyle(fontFamily: 'Montserrat'),
            prefixIcon: Icon(
              Icons.shopping_basket,
              color: Color.fromARGB(255, 121, 171, 245),
            ),
            border: OutlineInputBorder(
                borderRadius: BorderRadius.circular(10.0),
                borderSide: BorderSide(color: Colors.green, width: 3),
                gapPadding: 20.0),
          ),
        )

我正在尝试使用此代码更改 OutlineInputBorder 的边框颜色,但它没有改变。 它也不会增加侧面的宽度。

您尝试只设置border ,但您也应该设置enableBorderfocusedBorder ,在主题数据中设置这些,如下所示:

Theme(
            data: ThemeData(
              inputDecorationTheme: InputDecorationTheme(
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(10.0),
                  borderSide: BorderSide(color: Colors.green, width: 3),
                  gapPadding: 20.0,
                ),
                enabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(10.0),
                  borderSide: BorderSide(color: Colors.green, width: 3),
                  gapPadding: 20.0,
                ),
                focusedBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(10.0),
                  borderSide: BorderSide(color: Colors.green, width: 3),
                  gapPadding: 20.0,
                ),
              ),
            ),
            child: TextFormField(
              decoration: InputDecoration(
                labelText: 'Ürün',
                labelStyle: TextStyle(fontFamily: 'Montserrat'),
                prefixIcon: Icon(
                  Icons.shopping_basket,
                  color: Color.fromARGB(255, 121, 171, 245),
                ),
                
              ),
            ),
          ),

在此处输入图像描述

尝试添加此装饰:

decoration: InputDecoration(
        hintText: "Hint",
        counterText: "",
        isDense: true,
        alignLabelWithHint: true,
        floatingLabelBehavior: FloatingLabelBehavior.always,
        contentPadding: EdgeInsets.fromLTRB(0.w, 2.h, 5.w, 1.7.h),
        enabledBorder: UnderlineInputBorder(
            borderSide: BorderSide(color: Theme.of(context).focusColor)),
        focusedBorder: UnderlineInputBorder(
            borderSide: BorderSide(
                color: Theme.of(context).primaryColor, width: 0.5.w)),
        disabledBorder: UnderlineInputBorder(
            borderSide: BorderSide(color: Theme.of(context).focusColor)),
      ),

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM