如何在Flutter中做焦点节点和颜色变化

pdsfdshx  于 2023-05-19  发布在  Flutter
关注(0)|答案(1)|浏览(216)

设计:

以上设计的Flutter代码

nhaq1z21

nhaq1z211#

你可以使用这个代码:

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,
    );
  }

}

相关问题