颤抖的YouTube风格图片黑色叠加

时间:2020-06-10 15:36:33

标签: flutter dart

如何在颤抖中达到这种效果?

flutter overlay image

2 个答案:

答案 0 :(得分:3)

这将起作用

Container(
        height: 200,
        child: Stack(
          children: [
            Image.network(
              'https://cdn.motor1.com/images/mgl/rBzVX/s1/most-expensive-cars.jpg',
              fit: BoxFit.cover,
            ),
            Container(
              height: 200,
              width: double.infinity,
              color: Colors.black54,
            ),
            Align(
              alignment: Alignment.centerRight,
              child: Container(
                height: 200,
                width: 100,
                color: Colors.black,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(
                      '50+',
                      style: TextStyle(
                          color: Colors.white,
                          fontWeight: FontWeight.bold,
                          fontSize: 16),
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Icon(
                      Icons.play_circle_outline,
                      color: Colors.white,
                      size: 30,
                    )
                  ],
                ),
              ),
            ),
            Align(
              alignment: Alignment.center,
              child: Row(
                mainAxisSize: MainAxisSize.min,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Icon(
                    Icons.play_arrow,
                    color: Colors.white,
                    size: 30,
                  ),
                  Text(
                    'PLAY ALL',
                    style: TextStyle(
                        color: Colors.white,
                        fontWeight: FontWeight.bold,
                        fontSize: 16),
                  )
                ],
              ),
            ),
          ],
        ),

答案 1 :(得分:0)

您可以独立创建每个小部件(预览缩略图,播放列表按钮,覆盖按钮)。然后使用Stack Widget将一个小部件放置在另一个小部件上

要提供透明度,您可以使用Opacity Widget 不透明度(child:OverlayWidget(),不透明度:0.50,)