TextField Flutter 中未显示光标和文本

Cursor and text not showing in TextField Flutter

当我单击 TextField 时,我的光标和我在文本字段中键入的文本没有显示。似乎我一如既往地做所有事情,但由于某种原因没有显示任何内容。请告诉我我的错误是什么?

正文

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

删除包裹 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,
        ),
    ),
),