[Flutter Layout] FittedBox, FractionallySizedBox, LimitedBox

김기현·2025년 3월 6일

Flutter Layout

목록 보기
6/8

FittedBox

자식 위젯들의 크기를 부모의 크기에 따라 어떻게 맞출 것인가

Constructor

FittedBox({Key? key, BoxFit fit = BoxFit.contain, AlignmentGeometry alignment = Alignment.center, Clip clipBehavior = Clip.none, Widget? child})

Properties

  • alignment(AlignmentGeometry)
    • 자식위젯을 부모의 범위 내에 맞추는 방법.
  • child(Widget?)
    • 자식위젯들
  • clipBehavior(Clip)
  • fit(BoxFit)
    • fill, contain, cover, fitWidth, fitHeight, none등 사용하여 부모의 크기에 따라 배치됨

FractionallySizedBox

자식위젯의 가능한 공간안에서 크기를 조절한다.

Constructor

FractionallySizedBox({Key? key, AlignmentGeometry alignment = Alignment.center, double? widthFactor, double? heightFactor, Widget? child})

Properties

  • alignment(AlignmentGeometry)
    • 어떻게 자식을 배치할 것인가?
  • child
  • heightFactor(double?)
    • 1.0이면 부모의 높이와 동일 0.5라면 절반이다
  • widthFactor(double?)
    • 1.0이면 부모의 너비와 동일 0.5라면 절반이다

LimitedBox

부모의 높이나 넓이가 무제한 일 때 사용한다.
자식의 크기를 제한할 수 있다.
무한 스크롤의 리스트 뷰일 때 유용하다.

Constructor

LimitedBox({Key? key, double maxWidth = double.infinity, double maxHeight = double.infinity, Widget? child})

Properties

  • child(Widget?)
  • maxHeight(double)
    • BoxConstraints.maxHeight 제약 조건이 없는 경우 적용할 최대 높이 제한
  • maxWidth(double)
    • BoxConstraints.maxWidth 제약 조건이 없는 경우 적용할 최대 너비 제한

0개의 댓글