【发布时间】:2023-01-13 08:17:02
【问题描述】:
我只想构建一个带有标题和底部标签栏的简单 SliverAppBar 但由于我需要降低标签栏高度我使用 preferredsize 然后它看起来像这样,标题不会完全折叠,我想固定标签栏但标题没有'倒塌
SliverAppBar(
iconTheme: const IconThemeData(color: Colors.white),
backgroundColor: Colors.transparent,
elevation: 0,
floating: true,
snap: true,
pinned: true,
automaticallyImplyLeading: false,
title: const Text(
'LIVE',
style: TextStyle(color: MyThemes.colorWhite),
),
actions: [
IconButton(
onPressed: () {},
icon: Image.asset(
'assets/icons/general/icon-search.png',
width: 16,
height: 16,
),
),
],
flexibleSpace: FlexibleSpaceBar(
background: Container(
decoration: const BoxDecoration(
color: Colors.red,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.black, Colors.transparent],
),
),
),
),
bottom: PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight),
child: SizedBox(
height: 36,
child: TabBar(
overlayColor: MaterialStateProperty.all(Colors.transparent),
indicatorPadding: EdgeInsets.zero,
indicator: const ShapeDecoration(
shape: StadiumBorder(),
color: MyThemes.colorBlue,
),
isScrollable: true,
tabs: const [
Tab(text: 'Layar Hiburan'),
Tab(text: 'Layar Berita'),
],
),
),
),
);
【问题讨论】: