Align
자식 위젯의 정렬 방향을 정하는 위젯
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Align'),
),
body: Align( // Align 자식 위젯의 정렬 방향을 정할 수 있는 위젯이다.
alignment: Alignment.bottomRight, // 말그대로 오른쪽하단
child: Container (
color: Colors.red,
width: 100,
height: 100,
),
),
);
}
}
Alignment 클래스에 정의 되어 있는 정렬 관련 상수들
bottomLeft
bottomCenter
bottomRight
centerLeft
center
centerRight
topLeft
topCenter
topRight
: 9등분 되어있다.
Expanded
자식 위젯의 크기를 최대한으로 확장시켜주는 위젯
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Expanded'),
),
body: Column(children: <Widget>[
Expanded(
flex: 2, // 비율
child: Container(
color: Colors.red,
),
),
Expanded(
// 비율 명시안하면 기본값 1이다.
child: Container(
color: Colors.green,
),
),
Expanded(
child: Container(
color: Colors.blue,
)),
]),
);
}
}
'백엔드개발자 > FLUTTER, DART' 카테고리의 다른 글
[Flutter] 화면 이동 Navigator(push, pop)과 데이터 전달 (0) | 2022.06.30 |
---|---|
[Flutter] TextField (0) | 2022.06.30 |
[Flutter] AppBar, TabBar, Tab, TabBarView, bottomNavigationBar (0) | 2022.06.27 |
[Flutter] ListView, ListTile, scrollDirection, GridView, PageView, Padding (0) | 2022.06.26 |
[Flutter] Row, MeterialApp title, SingleChildScrollView (0) | 2022.06.26 |