복수 위젯담는 박스(컨테이너) 작성
Column (칼럼, 열, 세로축)
Row (로우, 행, 가로축)
Wrap (children에 공간이 부족해지면 자동으로 다음 줄로 바꿔줍니다)
Stack (children의 위젯들을 겹쳐서 출력합니다)
컨테이너 박스를 세로로 나열할 때
body: Column(
children: [
Container(
color: Colors.red,
width: 150,
height: 300,
child: const Text(
'1',
),
),
Container(
color: Colors.yellow,
width: 150,
height: 300,
child: const Text(
'2',
),
),
Container(
color: Colors.green,
width: 150,
height: 300,
child: const Text(
'3',
),
),
],
),
body: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
color: Colors.red,
width: 150,
height: 300,
child: const Text(
'1',
),
),
],
),
mainAxisAlignment: MainAxisAlignment.center,
body: Row(
children: [
Container(
color: Colors.red,
width: 150,
height: 300,
child: const Text(
'1',
),
),
Container(
color: Colors.yellow,
width: 150,
height: 300,
child: const Text(
'2',
),
),
Container(
color: Colors.green,
width: 150,
height: 300,
child: const Text(
'3',
),
),
],
),
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
overflow났을 때 다음 줄로 내리고싶을때
children에 공간이 부족해지면 자동으로 다음 줄로 바꿔줍니다
body: Wrap(
// direction: Axis.vertical,
children: [
Container(
color: Colors.red,
width: 150,
height: 300,
child: const Text(
'1',
),
),
Container(
color: Colors.yellow,
width: 150,
height: 300,
child: const Text(
'2',
),
),
Container(
color: Colors.green,
width: 150,
height: 300,
child: const Text(
'3',
),
),
],
),
겹쳐서 위젯을 출력하고 싶을 때
children의 위젯들을 겹쳐서 출력합니다
body: Stack(
alignment: Alignment.center,
children: [
Container(
color: Colors.red,
alignment: Alignment.center,
width: 100,
height: 200,
child: const Text(
'1',
),
),
Container(
color: Colors.green,
alignment: Alignment.center,
width: 100,
height: 100,
child: const Text(
'2',
),
),
Container(
color: Colors.yellow,
alignment: Alignment.center,
width: 100,
height: 50,
child: const Text(
'3',
),
),
],
)