[英]Why it shows two AppBars after adding 'Sliver AppBar' in flutter App
我在我的应用程序的脚手架中添加了“Sliver AppBar”,我想知道为什么它现在显示两个应用程序栏。 Scaffold 仅包含一个抽屉,但在 UI 中,它显示了两个抽屉。 任何人都知道出了什么问题。
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
bottom: AppBar(
title: SizedBox(
height: 45,
child: TextField(
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 5, left: 15),
suffixIcon: IconButton(
icon: Icon(Icons.search),
onPressed: () {
},
),
filled: true,
fillColor: Colors.white,
hintText: "What are you looking for ?",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
),
),
),
),
),
),
drawer: Drawer(),
);
从代码中删除 SliverAppBar 后,它显示空白屏幕。 因此,可以确认这两个 AppBar 仅来自上述代码。
SliverAppBar
本身是一个appBar
和bottom: AppBar
是另一个,您可以在bottom
使用PreferredSize
。
SliverAppBar(
bottom: PreferredSize(
preferredSize: Size.fromHeight(45),
child: TextField(
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.