Flutter Inherited Custom AppBar 在 TextField 点击时消失
Flutter Inherited Custom AppBar disappear on TextField tap
我根据以下代码在脚手架中使用自定义 appBar 和 bottomNavigationBar:
return Scaffold(
appBar: LogoAppBar(),
drawer: topDrawer(),
body: _pageOptions[_selectedTab],
bottomNavigationBar: BottomNavigationBar(...)
当我通过 BottomNavigationBar 导航时,自定义 AppBar 会停留在新屏幕的顶部,就像我想要的那样。
但是,当我导航然后点击新屏幕上的 TextField 以输入一些文本时,继承的 AppBar 会自动消失(当键盘出现时)。
此屏幕的完整代码相当长,因此 post 这里不太实用,但基本上可以归结为以下内容:
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children: [
Container(
Column(
children: [
DropDownButton(...),
TextField(...), // with a textSearchController
],
Expanded(
child: ListViewBuilder(...) // showing a list based on the search
有没有什么方法可以使继承的 class 的 AppBar 保持不变,而无需在我导航到的 class 的脚手架中放置新的 appBar?
尝试删除 Scaffold,因为您已经在主屏幕中调用过它一次。
return Column(
children: [
Container(
Column(
children: [
DropDownButton(...),
TextField(...), // with a textSearchController
],
Expanded(
child: ListViewBuilder(...)
Ujjwal 的建议非常有用。我删除了 Scaffold,不幸的是问题仍然存在,但这让我意识到我也将 LogoAppBar() 代码包装在 Scaffold 中。一旦我从 LogoAppBar() 中删除了脚手架,它就全部工作了!
我根据以下代码在脚手架中使用自定义 appBar 和 bottomNavigationBar:
return Scaffold(
appBar: LogoAppBar(),
drawer: topDrawer(),
body: _pageOptions[_selectedTab],
bottomNavigationBar: BottomNavigationBar(...)
当我通过 BottomNavigationBar 导航时,自定义 AppBar 会停留在新屏幕的顶部,就像我想要的那样。
但是,当我导航然后点击新屏幕上的 TextField 以输入一些文本时,继承的 AppBar 会自动消失(当键盘出现时)。
此屏幕的完整代码相当长,因此 post 这里不太实用,但基本上可以归结为以下内容:
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children: [
Container(
Column(
children: [
DropDownButton(...),
TextField(...), // with a textSearchController
],
Expanded(
child: ListViewBuilder(...) // showing a list based on the search
有没有什么方法可以使继承的 class 的 AppBar 保持不变,而无需在我导航到的 class 的脚手架中放置新的 appBar?
尝试删除 Scaffold,因为您已经在主屏幕中调用过它一次。
return Column(
children: [
Container(
Column(
children: [
DropDownButton(...),
TextField(...), // with a textSearchController
],
Expanded(
child: ListViewBuilder(...)
Ujjwal 的建议非常有用。我删除了 Scaffold,不幸的是问题仍然存在,但这让我意识到我也将 LogoAppBar() 代码包装在 Scaffold 中。一旦我从 LogoAppBar() 中删除了脚手架,它就全部工作了!