簡體   English   中英

顫動更改文本字段下划線顏色

[英]Flutter change textfield underline Color

當文本字段處於非活動狀態/未聚焦時,我試圖更改它的下划線顏色。 我不確定在哪里進行此更改, InputDecorationTheme僅在選擇時更改下划線顏色。 我如何實現這一目標?

inputDecorationTheme: new InputDecorationTheme(
          labelStyle: new  TextStyle(
              color: Colors.blue[200],
          ),
          hintStyle: new TextStyle(color: Colors.grey),
        ),

當文本字段未被選中/失焦時,我試圖將文本字段的這種顏色更改為較淺的灰色。

在此處輸入圖片說明

對於那些可能需要實現類似目標的人,請更改Theme小部件中的hintColor

new Theme(
          data: new ThemeData(
              //this changes the colour
              hintColor: Colors.grey,
              inputDecorationTheme: new InputDecorationTheme(
                  labelStyle: new TextStyle(color: Colors.blue))));

我們可以使用InputDecoration

試試這個方法

 new TextFormField(
                        controller: passTextController,
                        decoration: new InputDecoration(
                            labelText: "Enter password",
                            enabledBorder: UnderlineInputBorder(
                              borderSide: BorderSide(color: Colors.grey),
                              //  when the TextFormField in unfocused 
                            ) ,
                            focusedBorder: UnderlineInputBorder(
                              borderSide: BorderSide(color: Colors.blue),
                              //  when the TextFormField in focused 
                            ) ,
                            border: UnderlineInputBorder(
                            )
                        ),
                        keyboardType: TextInputType.text,
                        obscureText: true,
                      ),

輸出

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM