在Flutter中如何进行焦点节点和颜色变化。

huangapple go评论58阅读模式
英文:

How to do focus node and colour change in flutter

问题

设计:

![](https://i.stack.imgur.com/eEoYm.png)

上述设计的Flutter代码
英文:

Design:

在Flutter中如何进行焦点节点和颜色变化。

Flutter code for the above design

答案1

得分: 1

以下是代码的中文翻译:

你可以使用这段代码:

class InputFil extends StatelessWidget{
  String Labletext;
  IconData RightIcon;
  IconButton ?LeftIcon;
  bool ShowPass;
  TextEditingController ?Control;
  TextInputType KeyType;
  final validator;



  InputFil({required this.Labletext,required this.RightIcon, this.LeftIcon,required this.ShowPass, this.Control,required this.KeyType,this.validator,});

  @override
  Widget build(BuildContext context) {
    return TextFormField(
      controller: Control,
      obscureText: ShowPass,
      validator: validator,
      style: TextStyle(color: Colors.white,fontSize: 15),
      decoration: InputDecoration(
        enabledBorder: OutlineInputBorder(
          borderSide: BorderSide(width: 1.5, color: Colors.white),
        ),
        ////你的答案.
        focusedBorder: OutlineInputBorder(
          borderSide: BorderSide(width: 1.5, color: Colors.white), ),
        prefixIcon: Icon(RightIcon,color: Colors.white,),
        contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
        labelText: Labletext,
        suffixIcon : LeftIcon,
        labelStyle: TextStyle(color: Colors.white),
        iconColor: Colors.white,
        suffixIconColor: Colors.white,
        prefixIconColor: Colors.white,

        border: OutlineInputBorder(borderRadius: BorderRadius.circular(10.0)),
      ),
      keyboardType: KeyType,
    );
  }

}

希望对你有所帮助!如果你有任何其他问题或需要进一步的帮助,请随时告诉我。

英文:

You can use this code :

class InputFil extends StatelessWidget{
  String Labletext;
  IconData RightIcon;
  IconButton ?LeftIcon;
  bool ShowPass;
  TextEditingController ?Control;
  TextInputType KeyType;
  final  validator;




  InputFil({required this.Labletext,required this.RightIcon, this.LeftIcon,required this.ShowPass, this.Control,required this.KeyType,this.validator,});

  @override
  Widget build(BuildContext context) {
    return TextFormField(
      controller: Control,
      obscureText: ShowPass,
      validator: validator,
style: TextStyle(color: Colors.white,fontSize: 15),
      decoration: InputDecoration(
        enabledBorder: OutlineInputBorder(
          borderSide: BorderSide(width: 1.5, color: Colors.white),
        ),
        ////your answer.
        focusedBorder: OutlineInputBorder(
          borderSide: BorderSide(width: 1.5, color: Colors.white), ),
        prefixIcon: Icon(RightIcon,color: Colors.white,),
        contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
        labelText: Labletext,
        suffixIcon : LeftIcon,
        labelStyle: TextStyle(color: Colors.white),
        iconColor: Colors.white,
        suffixIconColor: Colors.white,
        prefixIconColor: Colors.white,

        border: OutlineInputBorder(borderRadius: BorderRadius.circular(10.0)),
      ),
      keyboardType: KeyType,
    );
  }

}

huangapple
  • 本文由 发表于 2023年5月11日 16:24:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76225569.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定