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

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

How to do focus node and colour change in flutter

问题

  1. 设计:
  2. ![](https://i.stack.imgur.com/eEoYm.png)
  3. 上述设计的Flutter代码
英文:

Design:

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

Flutter code for the above design

答案1

得分: 1

以下是代码的中文翻译:

  1. 你可以使用这段代码:
  2. class InputFil extends StatelessWidget{
  3. String Labletext;
  4. IconData RightIcon;
  5. IconButton ?LeftIcon;
  6. bool ShowPass;
  7. TextEditingController ?Control;
  8. TextInputType KeyType;
  9. final validator;
  10. InputFil({required this.Labletext,required this.RightIcon, this.LeftIcon,required this.ShowPass, this.Control,required this.KeyType,this.validator,});
  11. @override
  12. Widget build(BuildContext context) {
  13. return TextFormField(
  14. controller: Control,
  15. obscureText: ShowPass,
  16. validator: validator,
  17. style: TextStyle(color: Colors.white,fontSize: 15),
  18. decoration: InputDecoration(
  19. enabledBorder: OutlineInputBorder(
  20. borderSide: BorderSide(width: 1.5, color: Colors.white),
  21. ),
  22. ////你的答案.
  23. focusedBorder: OutlineInputBorder(
  24. borderSide: BorderSide(width: 1.5, color: Colors.white), ),
  25. prefixIcon: Icon(RightIcon,color: Colors.white,),
  26. contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
  27. labelText: Labletext,
  28. suffixIcon : LeftIcon,
  29. labelStyle: TextStyle(color: Colors.white),
  30. iconColor: Colors.white,
  31. suffixIconColor: Colors.white,
  32. prefixIconColor: Colors.white,
  33. border: OutlineInputBorder(borderRadius: BorderRadius.circular(10.0)),
  34. ),
  35. keyboardType: KeyType,
  36. );
  37. }
  38. }

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

英文:

You can use this code :

  1. class InputFil extends StatelessWidget{
  2. String Labletext;
  3. IconData RightIcon;
  4. IconButton ?LeftIcon;
  5. bool ShowPass;
  6. TextEditingController ?Control;
  7. TextInputType KeyType;
  8. final validator;
  9. InputFil({required this.Labletext,required this.RightIcon, this.LeftIcon,required this.ShowPass, this.Control,required this.KeyType,this.validator,});
  10. @override
  11. Widget build(BuildContext context) {
  12. return TextFormField(
  13. controller: Control,
  14. obscureText: ShowPass,
  15. validator: validator,
  16. style: TextStyle(color: Colors.white,fontSize: 15),
  17. decoration: InputDecoration(
  18. enabledBorder: OutlineInputBorder(
  19. borderSide: BorderSide(width: 1.5, color: Colors.white),
  20. ),
  21. ////your answer.
  22. focusedBorder: OutlineInputBorder(
  23. borderSide: BorderSide(width: 1.5, color: Colors.white), ),
  24. prefixIcon: Icon(RightIcon,color: Colors.white,),
  25. contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
  26. labelText: Labletext,
  27. suffixIcon : LeftIcon,
  28. labelStyle: TextStyle(color: Colors.white),
  29. iconColor: Colors.white,
  30. suffixIconColor: Colors.white,
  31. prefixIconColor: Colors.white,
  32. border: OutlineInputBorder(borderRadius: BorderRadius.circular(10.0)),
  33. ),
  34. keyboardType: KeyType,
  35. );
  36. }
  37. }

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:

确定