令图像取固定高度的列中剩下的空间
我得到了一个用约束框
用maxheight
包裹的列
。现在,我的列
有三个孩子。文本,图像和文本输入。我想将图像调整为绘制文本和文本输入后剩下的空间。我该如何实现?我的图像被加载在FutureBuilder
中。
我的代码:
ConstrainedBox(
constraints: BoxConstraints(maxHeight: 100.h)
child: Column(
children: [
Text(
"loading...",
style: TextStyle(fontSize: 15.sp, color: Colors.red),
),
FutureBuilder<String>(
future: imageRef.getDownloadURL(),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.hasData) {
String url = snapshot.data!;
return Image.network(
url
);
} else {
return Text(
AppLocalizations.of(context)!.loadingImageFailed,
style: TextStyle(
fontSize: 15.sp,
),
);
}
}),
Padding(
padding: EdgeInsets.only(left: 15.sp, right: 15.sp),
child: SizedBox(
width: 100.w,
child: ThemeInputField(
context,
_titleController,
AppLocalizations.of(context)!.memeTitleInputLabel,
textInputAction: TextInputAction.go,
size: 16.sp,
autofocus: true,
textColor: Colors.white,
)))
],
))
I got a Column
that is wrapped in a ConstrainedBox
with a maxHeight
. Now my Column
has three childs. A text, an image and a textinput. I want to have the image adjust to the space that is left after text and textinput were drawn. How can I achieve that? My Image is loaded in a FutureBuilder
.
At the moment it just overflows at the bottom because my Image is too big. it looks like this:
My Code:
ConstrainedBox(
constraints: BoxConstraints(maxHeight: 100.h)
child: Column(
children: [
Text(
"loading...",
style: TextStyle(fontSize: 15.sp, color: Colors.red),
),
FutureBuilder<String>(
future: imageRef.getDownloadURL(),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.hasData) {
String url = snapshot.data!;
return Image.network(
url
);
} else {
return Text(
AppLocalizations.of(context)!.loadingImageFailed,
style: TextStyle(
fontSize: 15.sp,
),
);
}
}),
Padding(
padding: EdgeInsets.only(left: 15.sp, right: 15.sp),
child: SizedBox(
width: 100.w,
child: ThemeInputField(
context,
_titleController,
AppLocalizations.of(context)!.memeTitleInputLabel,
textInputAction: TextInputAction.go,
size: 16.sp,
autofocus: true,
textColor: Colors.white,
)))
],
))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试用扩展的小部件包装image.network
另外,添加为参数the image.network boxfit.fill
try wrapping Image.network with an expanded widget
also, add as a parameter the Image.network boxFit.fill