본문 바로가기

개발/Flutter

Flutter. 이미지를 원형으로 crop해보자

반응형

 

default로 로드한 이미지의 경우 위와 같은 모양을 하고 있지만

요구사항에 의해 원형으로 만들어야 한다면 다음과 같은 방법으로 가능하다. 

 

 

 

 

방법 1. 

Container(
    width: 80,
    height: 80,
    decoration: BoxDecoration(
        shape: BoxShape.circle,
        image: DecorationImage(
          fit: BoxFit.fill,
          image: AssetImage('assets/img/music.png'),
        )
    )
);

 

 

 

 

방법 2. 

CircleAvatar(
  radius: 40,
  backgroundImage: AssetImage('assets/img/home-delivery.png'),
);
반응형