
Container๋ ๋ฐ์ค ๋ชจ๋ธ(Box Model) ๊ฐ๋
๊ธฐ๋ฐ์ผ๋ก ๋ง๋ค์ด์ง ์์ ฏ
๋ด๋ถ์ ์์ ฏ์ ๋ด๊ณ ํฌ๊ธฐ, ํจ๋ฉ, ๋ง์ง, ์ฅ์ ๋ฑ์ ์ง์ ํ ์ ์๋ ๋ค๋ชฉ์ ๋ฐ์ค ์ญํ ์ ํจ
์ฃผ๋ก ๋ ์ด์์, ์คํ์ผ๋ง, ๋ฐฐ๊ฒฝ ์ฅ์ ์ฉ๋๋ก ์ฌ์ฉ
| ์์ฑ | ์ค๋ช | ์์ |
|---|---|---|
child | Container ์์ ๋ด์ ์์ ฏ | child: Text('Hello') |
width | ๊ฐ๋ก ํฌ๊ธฐ | width: 100 |
height | ์ธ๋ก ํฌ๊ธฐ | height: 50 |
padding | ๋ด๋ถ ์ฌ๋ฐฑ | padding: EdgeInsets.all(8) |
margin | ์ธ๋ถ ์ฌ๋ฐฑ | margin: EdgeInsets.symmetric(horizontal: 16) |
color | ๋ฐฐ๊ฒฝ์ | color: Colors.blue |
decoration | ๋ฐ์ค ์ฅ์(์, ๊ทธ๋ฆผ์, ํ ๋๋ฆฌ, ๊ทธ๋ผ๋ฐ์ด์ ๋ฑ) | BoxDecoration(borderRadius: BorderRadius.circular(8)) |
alignment | child ์์น ์กฐ์ | alignment: Alignment.center |
constraints | ์ต์/์ต๋ ํฌ๊ธฐ ์ ํ | BoxConstraints(minWidth: 50, maxWidth: 200) |
transform | 2D ๋ณํ(ํ์ , ์ด๋ ๋ฑ) | transform: Matrix4.rotationZ(0.1) |
Container(
width: 150,
height: 100,
padding: EdgeInsets.all(12),
margin: EdgeInsets.symmetric(horizontal: 16),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 4,
offset: Offset(2, 2),
)
],
),
child: Text(
'Flutter Container',
style: TextStyle(color: Colors.white),
),
)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16), // margin
child: SizedBox(
width: 150,
height: 100,
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 4,
offset: Offset(2, 2),
),
],
),
child: Padding(
padding: const EdgeInsets.all(12), // padding
child: Center(
child: Text(
'Container',
style: TextStyle(color: Colors.white),
),
),
),
),
),
)
ํ
์คํธ๋ฅผ ๋๋๊ทธํด์ ์ ํ / ๋ณต์ฌํ ์ ์๊ฒ ํด์ฃผ๋ ์์ ฏ
์ผ๋ฐ Text ์์ ฏ๊ณผ์ ๊ฐ์ฅ ํฐ ์ฐจ์ด์ ์
์ ์ ์ธํฐ๋์
(์ ํ, ๋ณต์ฌ) ๊ฐ๋ฅ ์ฌ๋ถ
ํ์ ์์ ฏ ์ ์ฒด๋ฅผ ํ๋์ โ์ ํ ๊ฐ๋ฅํ ์์ญโ์ผ๋ก ๋ง๋ค์ด์ฃผ๋ ์์ ฏ
์ค๋๋ ์ด์๋ฏธ ํํ์ ํ๋ค.. ํํ..