首页 > 解决方案 > AnimatedSwitcher 切换后保持 TextField 键盘打开?

问题描述

AnimatedSwitcher用于在 2 个小部件之间切换:

AnimatedSwitcher(
  duration: const Duration(milliseconds: 200),
  child:
  toggle
      ? TextField()
      : otherWidget(),

问题是当 AnimatedSwitcher 从 Textfield 切换离开时,即使用户已经点击它并打开键盘,它也会关闭键盘。

即使小部件更改,如何保持键盘打开AnimatedSwitcher

标签: flutterdartflutter-animation

解决方案


推荐阅读