본문 바로가기

Flutter

[j Flutter] 이미지 투명도 조절

728x90
반응형

flutter에서 이미지 투명도 조절하는 법

 

 Container(
                decoration: BoxDecoration(
                  image: DecorationImage(
                    fit: BoxFit.cover,
                    colorFilter: ColorFilter.mode(
                        Colors.black.withOpacity(0.1), BlendMode.dstATop),
                    image: NetworkImage('이미지 주소'),
                  ),
                ),
                height: 300,
              )

 

- colorFilter: ColorFilter.mode(Colors.black.withOpacity(0.1), BlendMode.dstATopBlendMode.dstATop)에서 withOpacity값을

변경하여 투명도를 조절한다.

0 ~ 1 사이의 값을 입력한다. 0일 수록 투명해지고 1로 가까워질수록 불투명해진다. 

 

- BlendMode의 설명은 아래의 링크에 잘 나와있다.

api.f lutter.dev/flutter/dart-ui/BlendMode-class.html

 

BlendMode enum - dart:ui library - Dart API

BlendMode enum Null safety Algorithms to use when painting on the canvas. When drawing a shape or image onto a canvas, different algorithms can be used to blend the pixels. The different values of BlendMode specify different such algorithms. Each algorithm

api.flutter.dev

 

728x90
반응형