在我的第二次AppBar Flutter上奇怪的顶部填充



我的应用程序的奇怪的顶部填充屏幕

我做了两个类:第一个类有第一个AppBar,并调用第二个类,这个类也有一个sticky AppBar,并显示一个可滚动项列表。然而,我有一个奇怪的顶部填充在第二个AppBar。我试了很多方法,但似乎都不起作用。

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
extendBodyBehindAppBar: true,
bottomNavigationBar: BottomNavBar(0, _currentAccount),
appBar: PreferredSize(
preferredSize:
Size.fromHeight(MediaQuery.of(context).size.height / 7),
child: Column(
children: [
Container(
width: MediaQuery.of(context).size.width,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: <Color>[
Color(0xFF894c56),
Color(0xFFa80d0d)
])),
child: Padding(
padding: const EdgeInsets.only(bottom: 30),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.only(top: 50, left: 5),
child: Text(
'Votre évenement ',
style: TextStyle(
fontSize: 15, color: Colors.grey),
)),
Padding(
padding: const EdgeInsets.only(top: 5, left: 5),
child: Text(
event,
style: const TextStyle(
color: Colors.white, fontSize: 17),
),
)
])),
)
],
),
),
body: ListPrestat('Traiteur', _currentAccount)
// ListPrestat('Traiteur', _currentAccount)
));
}

这是我的第一个类的代码,它调用ListPrestat类在这里:

@override
Widget build(BuildContext context) {
return SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height   ,
//   -(MediaQuery.of(context).size.height / 6 + 56),
child: CustomScrollView(
slivers: [
SliverAppBar(
toolbarHeight: 50,
expandedHeight: 0,
backgroundColor: const Color(0xFFDCDCDC),
pinned: true,
leading: IconButton(
icon: const Icon(
Icons.arrow_back,
color: Color(0xFFDC3535),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MainScreen(_currentAccount)),
);
},
),
centerTitle: true,
shadowColor: Colors.black,
elevation: 10,
bottom: const PreferredSize(
preferredSize: Size.fromHeight(0),
child: TagList(ListCat: 'brouette')),
title: Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(MediaQuery.of(context).size.width / 4),
child: Text(
_currentCat,
style: const TextStyle(
color: Colors.black,
fontSize: 16.0,
fontWeight: FontWeight.w700,
),
)),
),
SliverFixedExtentList(
itemExtent: 110.0,
delegate: SliverChildListDelegate(
[
for (int index = 0; index < 5; index++)
CustomListItem2(
thumbnail: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: AspectRatio(
child: Image.network(
growableList[index],
width: 100.0,
height: 100.0,
fit: BoxFit.fill,
),
aspectRatio: 1 / 1,
)),
title: 'Chez Luigi',
subtitle: 'Les meilleurs pizza hors d'italie.',
ListCat: 'Food Truck',
),
],
),
)
],
),
);
}

你知道是什么原因导致了这个填充和如何解决这个问题吗?

用scaffold包装第二个类

Scaffold(
body: SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height ,),
...................
)

最新更新