I am trying to design a TextField
with a button as a suffixIcon
. The problem is that the button is not covering the entire suffixIcon
area.
Consider the following example:
class ActionableTextField extends StatelessWidget {
const ActionableTextField({
super.key,
required this.labelText,
required this.controller,
required this.prefixIcon,
required this.suffixIcon,
required this.onPressed,
});
final TextEditingController controller;
final VoidCallback onPressed;
final IconData prefixIcon;
final IconData suffixIcon;
final String labelText;
@override
Widget build(BuildContext context) {
return TextField(
controller: controller,
decoration: InputDecoration(
labelText: labelText,
border: const OutlineInputBorder(),
prefixIcon: Icon(prefixIcon),
suffixIcon: ElevatedButton(
onPressed: onPressed,
child: Icon(suffixIcon),
),
),
);
}
}
If you take an actual look at the rendering output of ActionableTextField
, you will notice that the ElevatedButton
will not completely cover the suffixIcon
area. How can this be fixed?
The expected rendering output should look as follows:
The actual rendering output is looking as follows: