如何在抖动中制作可调节的图像容器

问题描述 投票:0回答:1

当容器的高度大于图像但覆盖范围不同时,图像应覆盖。在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),
      ),
    ),

下面的图像是我希望实现的过渡,但是使用上面的代码,图像尺寸保持不变,并且不会调整大小。

enter image description here

enter image description here

flutter dart flutter-layout flutter-animation
1个回答
0
投票

解决者;

 flexibleSpace: Container(
        decoration: BoxDecoration(
          image: DecorationImage(
              image: ExactAssetImage('assets/caesar-salad.png'),
              fit: BoxFit.cover),
        ),
      ),
© www.soinside.com 2019 - 2024. All rights reserved.