Container 를 사용해서 DecorationImage 로 설정하기
class OnHomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
var imagePath ='https://cdn.pixabay.com/photo/2023/11/26/08/27/leaves-8413064_640.jpg';
return Scaffold(
body: Container(
decoration: BoxDecoration(
color: Colors.white,
image: DecorationImage(image: NetworkImage(imagePath), fit: BoxFit.cover),
),
child: Center(child: Text("Home screen", style: TextStyle(fontSize: 40))),
) ); }}
Scaffold를 Container의 child로 설정할 수도 있다.
스케폴드의 backgroundColor: Colors.transparent, 투명도를 설정해 준다.
class OnHomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
var imagePath = 'https://cdn.pixabay.com/photo/2023/11/26/08/27/leaves-8413064_640.jpg';
return Container(
decoration: BoxDecoration(
image: DecorationImage(image : NetworkImage(imagePath),fit: BoxFit.cover)
),
child: Scaffold(
backgroundColor: Colors.transparent,
body: Center(child: Text("Home screen", style: TextStyle(fontSize: 40))),
));
}
}
Container 에 Container 를 이용해서 layer 효과를 줄 수 있다.
Container(
decoration: BoxDecoration(
image: DecorationImage(image : NetworkImage(imagePath),fit: BoxFit.cover)
),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.center,
end: Alignment.bottomCenter,
colors: [Colors.black, Colors.brown]
)
),
child: Scaffold(
backgroundColor: Colors.transparent,
body: Center(child: Text("Home screen", style: TextStyle(fontSize: 40))),
),
));
아래와 같이 투명도를 설정하면 그라디언트가 예쁘게 잡힌다.
colors: [Colors.black12, Colors.black]
'Ui' 카테고리의 다른 글
flutter 키보드 입력 Overflow 해결 (0) | 2024.01.19 |
---|---|
Ui 패키지 없이 그라디에이션 꾸미기. (0) | 2023.12.19 |
Simple note Ui (1) | 2023.12.15 |
Ui Flutter Design Morphism 로그인 (0) | 2023.12.14 |
Ui login design (0) | 2023.12.12 |