[Flutter] SizedBox()

Tyger·2021년 10월 11일
1

SizedBox()

SizedBox는 widget의 크기를 다루는 위젯이다

기본 속성으로는 width, height만 있지만 SizedBox.expand(), SizedBox.shrink(), SizedBox.fromSize()도 사용하여 커스텀 가능함

주로 간격 조정시 padding을 많이 사용하지만 미세하게 높낮이를 조정하고 싶을 때 주로 SizedBox()를 사용함

SizedBox()를 사용시 앞에 const를 붙여주는 것이 성능에 유리함

나머지 속성은 다음에 다루겠음

 body: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: const [
              Text('Test'),
              SizedBox(width: 10),
              Text('App'),
            ],
          ),
          const SizedBox(height: 30),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Container(
                width: 100,
                height: 100,
                color: Colors.black,
              ),
              const SizedBox(width: 50),
              Container(
                width: 100,
                height: 100,
                color: Colors.teal,
              ),
            ],
          ),
        ],
      ),
profile
Flutter Developer

0개의 댓글