When I click on the TextField, my cursor and the text I type in the text field are not displayed. It seems that I do everything as always, but for some reason nothing is displayed. Please tell me what could be my mistake?
body
Padding(
padding: const EdgeInsets.symmetric(horizontal: 13),
child: SizedBox(
height: 45,
child: MySearchWidget(
onChanged: (value) => _runFilter(value),
),
),
),
MySearchWidget
Widget build(BuildContext context) {
return Row(
children: [
IconButton(
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
onPressed: () {
_onBackPressed(context);
},
icon: SvgPicture.asset(
constants.Assets.arrowLeft,
),
),
const SizedBox(
width: 14,
),
Expanded(
child: Container(
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(horizontal: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24),
color: constants.Colors.greyDark,
),
child: TextFormField(
onChanged: onChanged,
style: constants.Styles.textFieldTextStyleWhite,
cursorColor: Colors.white,
decoration: InputDecoration(
contentPadding: const EdgeInsets.only(
top: 15,
),
border: InputBorder.none,
prefixIcon: Align(
alignment: Alignment.centerLeft,
child: SvgPicture.asset(
constants.Assets.search,
width: 20,
height: 20,
),
),
),
),
),
),
],
);
}
CodePudding user response:
Remove the Align widget wrapping your prefixIcon.
TextFormField(
onChanged: onChanged,
style: constants.Styles.textFieldTextStyleWhite,
cursorColor: Colors.white,
decoration: InputDecoration(
contentPadding: const EdgeInsets.only(
top: 15,
),
border: InputBorder.none,
prefixIcon: FittedBox(
fit: BoxFit.scaleDown,
child: SvgPicture.asset(
'assets/svg/logo.svg',
width: 20,
height: 20,
),
),
),