I have created a customTextfield and placed IconButton as suffix icon,
here when I tap on icon button, its splash radius showing bigger than textfield,
here I want to fix height of splash radius based on it's parent.. like if it is inside of container of 100height..it must be set according to it...
here is my code
class CustomTextField extends StatelessWidget {
final String hint;
final bool isitpassword;
final TextEditingController controller;
const CustomTextField({Key? key,required this.hint,this.isitpassword=false,required this.controller}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(20),
),
child: TextField(
style: TextStyle(
fontSize: 20,color: Colors.white,),
controller: controller,
obscureText: isitpassword,
decoration: InputDecoration(
border: InputBorder.none,
hintText: hint,
suffixIcon: IconButton(
//what spread radius to set for better view
icon: Icon(Icons.close,color: Colors.white,),onPressed: (){
controller.text='';
},),
),
)),
);
}
}
CodePudding user response:
you can use InkWell
instead like this it will take size as much as its parent:
TextField(
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
controller: controller,
obscureText: isitpassword,
decoration: InputDecoration(
border: InputBorder.none,
hintText: hint,
suffixIcon: InkWell(
borderRadius: BorderRadius.circular(100),
child: Icon(
Icons.close,
color: Colors.white,
),
onTap: () {
controller.text = '';
},
)),
),
the 100
number is not important just set a big
number.
CodePudding user response:
You can use splashRadius: 48 / 2