Flutter
[Flutter] FractionallySizedBox
hymndaniel
2023. 6. 7. 12:53
하위 위젯들의 사이즈를 각 각 지정하지 않고 같은 UI를 구현하는 방법이 있다.
자식 위젯의 너비를 부모 위젯의 사이즈에 비례해서 만드는 FractionallySizedBox 위젯을 사용하는 것이다.
이 위젯은 widthFactor, heightFactor 라는 파라메터를 사용해서 부모 위젯 크기기에 비례하여 몇 배율로 해당위젯을 렌더링할 것인지 조작할 수 있다.
https://api.flutter.dev/flutter/widgets/FractionallySizedBox-class.html
FractionallySizedBox class - widgets library - Dart API
A widget that sizes its child to a fraction of the total available space. For more details about the layout algorithm, see RenderFractionallySizedOverflowBox. This sample shows a FractionallySizedBox whose one child is 50% of the box's size per the width a
api.flutter.dev
728x90