flutter - 如何在颤动中制作可调整的图像容器
问题描述
当容器的高度大于图像但覆盖范围不同时,图像应该覆盖。在 sliverappbar 上使用 boxfill 封面不会改变图像尺寸。
SliverAppBar(
title: Text('SliverAppBar'),
backgroundColor: Colors.green,
expandedHeight: MediaQuery.of(context).size.height,
flexibleSpace: FlexibleSpaceBar(
background:
Image.asset('assets/caesar-salad.png', fit: BoxFit.cover),
),
),
下面的图像是我希望实现的过渡,但是使用上面的代码,图像尺寸保持不变并且不会调整大小。
解决方案
解决了它;
flexibleSpace: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: ExactAssetImage('assets/caesar-salad.png'),
fit: BoxFit.cover),
),
),
推荐阅读
- javascript - d3-xyzoom:与 webpack 一起使用时,滚动(滚轮)缩放抛出“d3-xyzoom.js:83 Uncaught TypeError: Cannot read property 'button' of null”
- ruby - 将一个范围的每个项目分配给哈希中另一个范围的每个项目
- javascript - 单击选择/选项时的 JavaScript 新选项卡
- angular - 为什么 flushMicrotasks() 和 tick() 在 fakeAsync 中不执行 setImmediate 回调?
- django - Django 密码显示在表单数据(发布/请求)中
- python - 定位 ID 的最小值和最大值的数据框列
- apache-spark - 将每个 spark 数据框元素与同一数据框的所有其余部分进行比较
- mongodb - pgadmin4 的未完成安装不断阻止其他安装
- javascript - 为什么cypress看不到border *属性的css值?
- php - 替换txt文件中的空格和特殊字符