让图像取 space 留在固定高度的列中
Let image take space that is left in Column with fixed height
我得到了一个 Column
包裹在 ConstrainedBox
和 maxHeight
中。现在我的 Column
有了三个孩子。文本、图像和文本输入。我想让图像调整为绘制文本和文本输入后留下的 space。我怎样才能做到这一点?我的图片加载到 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,
)))
],
))
尝试使用扩展小部件包装 Image.network
另外,添加 Image.network boxFit.fill
作为参数
我得到了一个 Column
包裹在 ConstrainedBox
和 maxHeight
中。现在我的 Column
有了三个孩子。文本、图像和文本输入。我想让图像调整为绘制文本和文本输入后留下的 space。我怎样才能做到这一点?我的图片加载到 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,
)))
],
))
尝试使用扩展小部件包装 Image.network 另外,添加 Image.network boxFit.fill
作为参数