Overview .
minHeight , minWidth , maxHeight , maxWidth 를 지정할 수 있는 BoxConstraints 를 사용해보자
얘는 아무래도 많이 쓰이겠죠 ㅎㅎ
- BoxConstraints
0. 문서
https://api.flutter.dev/flutter/rendering/BoxConstraints-class.html
BoxConstraints class - rendering library - Dart API
Immutable layout constraints for RenderBox layout. A Size respects a BoxConstraints if, and only if, all of the following relations hold: The constraints themselves must satisfy these relations: double.infinity is a legal value for each constraint. The box
api.flutter.dev
1. BoxConstraints
뭐 없어요 바로 본문인데.. 설명이 필요한가요 ㅋㅋ
class _Home extends StatelessWidget {
const _Home({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
// 주석의 밑과 같이도 구성할 수 도 있다.
// child: Container(
// child: Text("안녕"),
// color: Colors.green,
// constraints: BoxConstraints(minHeight: 55 , minWidth: 100),
// ),
child: ConstrainedBox(
// ConstrainedBox 를 쓸바엔 BoxConstraints 를 쓰자
// minWidth , minHeight
// maxWidth , maxHeight 를 지정 할 수 있다.
constraints: BoxConstraints(
minWidth: 500,
),
child: ElevatedButton(
child: Text("Hello EveryOne"),
onPressed: () {},
),
),
),
);
}
}
'flutter & dart' 카테고리의 다른 글
flutter & dart - CustomScrollView (0) | 2024.04.01 |
---|---|
flutter & dart - SingleChildScrollView (0) | 2024.04.01 |
flutter & dart - CircularProgressIndicator (0) | 2024.04.01 |
flutter & dart - showModalBottomSheet (0) | 2024.04.01 |
flutter & dart - BottomNavigationBar , IndexedStack 위젯 (0) | 2024.04.01 |