본문 바로가기
TIL/Flutter

Flutter 플러터 앱개발-배경화면 이미지 적용하기

by 홍차23 2020. 6. 15.

How do I add a background image to flutter app?

 

How do I add a background image to flutter app?

I am trying to add a Background image to my Flutter App, and I have gone through all similar questions on SO. The app m runs fine but the image does not appear. here is my widget code: @overrid...

stackoverflow.com

 

Scaffold는 배경화면 이미지를 지원하지 않으므로, Container 위젯으로 감싸서 배경화면 이미지를 적용한다. Scaffold 에는 백그라운드에 transparent 값을 준다.

Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Container( //컨테이너로 감싼다.
        decoration: BoxDecoration( //decoration 을 준다.
            image: DecorationImage(
                image: AssetImage("images/logo.png"), fit: BoxFit.cover)),
        child: Scaffold(
          backgroundColor: Colors.transparent, //스캐폴드에 백그라운드를 투명하게 한다.
          appBar: AppBar(
            elevation: 0,
            backgroundColor: Colors.transparent,
            title: Text('My App'),
            centerTitle: true,
            leading: IconButton(
                icon: Icon(
                  Icons.list,
                  color: Colors.white,
                ),
                onPressed: () {}),
          ),
        ),
      ),
    );
  }

댓글