我在
ListView
内有一个 DefaultControllerTab
,由于某种原因,它在其上方创建了额外的间距,请检查图像。
return Scaffold(
appBar: AppBar(
title: Text(album.name ?? ''),
backgroundColor: context.primary.withOpacity(0.6),
),
body: const Stack(
children: [
AlbumHeader(),
Column(
children: [
Expanded(child: SizedBox.expand()),
Expanded(
flex: 2,
child: AlbumContentView(),
),
],
),
],
),
floatingActionButton: const RatingFloatingActionButton(),
extendBodyBehindAppBar: true,
);
小部件
AlbumContentView
是带有圆角的空白,这个:
return DecoratedBox(
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(32),
topRight: Radius.circular(32),
),
color: context.background,
),
child: const Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AlbumRating(),
SizedBox(
height: 16,
),
AlbumGenreList(),
SizedBox(
height: 16,
),
Expanded(child: AlbumTabView()),
],
),
),
).animate().fadeIn();
return DefaultTabController(
length: 3,
child: Column(
children: [
TabBar(
indicatorColor: context.primary,
labelColor: context.primary,
unselectedLabelColor: context.onSurface.withOpacity(0.6),
tabs: AlbumTabs.values
.map(
(e) => Tab(
icon: Icon(e.icon),
text: e.label,
),
)
.toList(),
),
const SizedBox(
height: 16,
),
const Expanded(
child: Material(
child: TabBarView(
children: [
AlbumAboutTabContent(),
AlbumTracksTabContent(),
Icon(Icons.directions_bike),
],
),
),
),
],
),
);
return ListView.builder(
itemCount: tracks.length,
itemBuilder: (context, index) => Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: InkWell(
onTap: () {},
borderRadius: BorderRadius.circular(8),
child: Ink(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(color: context.onSurface.withOpacity(0.2)),
),
child: Padding(
padding: const EdgeInsets.all(8),
child: Row(
children: [
Text(tracks[index].name!),
const Icon(Icons.arrow_outward),
],
),
),
),
),
),
);
我不知道那个额外的空白是什么,用“???”表示 谢谢
ListView 的顶部内边距默认设置为 20.0。如果你在Listview中添加零填充,你的问题就会消失。