gpt4 book ai didi

flutter - 如何去除 appBar 和 body 之间的空间?

转载 作者:行者123 更新时间:2023-12-05 06:02:13 27 4
gpt4 key购买 nike

在我的应用程序中,flutter 应用程序在应用程序栏和屏幕主体之间增加了空间。以下是屏幕图像: enter image description here

代码如下:

Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: true,
title: Container(
height: MediaQuery.of(context).size.width * 0.13,
child: Text('Dashboard')),
centerTitle: true,
backgroundColor: kBluePrimaryColor,
elevation: 0,
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: MediaQuery.of(context).size.height * 0.33,
child: Stack(children: [
Container(
//color: kBluePrimaryColor,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.23,
child: bannerimage == '' || bannerimage == null
? Image.asset('images/user.jpg')
: Image.network(
bannerimage),
),
Positioned(
top: MediaQuery.of(context).size.height * 0.16,
left: MediaQuery.of(context).size.width * 0.03,
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.height * 0.14,
height: MediaQuery.of(context).size.height * 0.14,
decoration: ShapeDecoration(
shape: CircleBorder(), color: Colors.white),
child: Padding(
padding: EdgeInsets.all(8.0),
child: DecoratedBox(
decoration: ShapeDecoration(
shape: CircleBorder(),
image: DecorationImage(
fit: BoxFit.cover,
image: imageurl == '' || imageurl == null
? AssetImage('images/user.jpg')
: NetworkImage(imageurl),
)),
),
),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.05,
),
],
),
),
Positioned(
top: MediaQuery.of(context).size.height * 0.24,
left: MediaQuery.of(context).size.height * 0.165,
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
color: kOrangePrimaryColor,
onPressed: () {
print('Contacts');
},
child: RichText(
text: TextSpan(
text: 'Total: ',
style:
TextStyle(color: Colors.white, fontSize: 12),
children: <TextSpan>[
TextSpan(
text: '30',
style: TextStyle(
color: Colors.white,
fontSize: 12,
fontWeight: FontWeight.bold,
fontFamily: 'Calibri')),
],
),
)),
SizedBox(
width: 13,
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
color: kBluePrimaryColor,
onPressed: () {
print('Address');
},
child: RichText(
text: TextSpan(
text: 'ADDRESS',
style: TextStyle(
color: Colors.white,
fontSize: 10,
fontWeight: FontWeight.bold,
fontFamily: 'Calibri')),
))
],
)),
),
]),
),
],
),
),
);
}

我尝试了给出的各种答案,但没有用。

我想删除蓝色应用栏和图像之间的空白区域。有人可以帮我解决这个问题吗?

最佳答案

我认为这是因为横幅图像没有填满容器尝试将 fit: BoxFit.cover 添加到图像中

关于flutter - 如何去除 appBar 和 body 之间的空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66984857/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com