๐ก ์คํ์ผ์ ๋ฃ์ ๋ ์์ ฏ๋ง๋ค ํ๋ํ๋ ์คํ์ผ์ ๋ฃ์ผ๋ฉด ์ฝ๋๊ฐ ๋๋ฌ์์ง๊ธฐ ๋๋ฌธ์ ThemaData() ์ฌ์ฉ
- MaterialApp() ์์ ThemeData() ์ด๊ธฐ
| MaterialApp( |
| theme : ThemeData(), |
| home : MyApp() |
| ) |
| ThemeData( |
| iconTheme: IconThemeData(color: Colors.red, size: 60), |
| appBarTheme: AppBarTheme( |
| color: Colors.grey, |
| ), |
| ) |
- ๋ชจ๋ ์์ด์ฝ ๋นจ๊ฐ์
- AppBar ํ์
โ AppBar ์์ actions: [] ์์ด์ฝ์ ๋นจ๊ฐ์์ผ๋ก ์ ์ฉ์ด ์๋๋ค๋ฉด?
- AppBarTheme() ์์ ์์ด์ฝ ์คํ์ผ ์ง์
- Text() ์คํ์ผ ๋ณ๊ฒฝ โ textTheme ์ฌ์ฉํ๋ฉด ๋จ
| ThemeData( |
| textTheme: TextTheme( |
| bodyText2: TextStyle( |
| color : Colors.blue, |
| ), |
| ), |
| ) |
- textTheme ์์๋ headline1, headline2, bodyText1 ๋ฑ์ ๊ธ์ ์คํ์ผ ์ข
๋ฅ๊ฐ ์์
- Text ์์ ฏ์ bodyText2 ์ฌ์ฉ
| ThemeData( |
| textButtonTheme: TextButtonThemeData( |
| style: TextButton.styleFrom( |
| primary: Colors.black, |
| backgroundColor: Colors.orange, |
| ) |
| ), |
| ) |
- styleFrom()์ ButtonStyle() ์ฌ๋ณธ์ ํ๋ ์์ฑํด์ฃผ๋ ํจ์
- ๋ ์ด์์ ์ค๊ฐ์ ThemeData() ํ๋ ์์ฑํ๋ฉด ๋จ
| Container( |
| child : Theme( |
| data : ThemeData(๊ธ์ ํ๋๊ฒ ํ๋ ์คํ์ผ~~), |
| child : Container( |
| ์ฌ๊ธฐ๋ถํฐ๋ ๊ธ์ ํ๋์ง~~ |
| ) |
| ) |
| ) |
Text('์๋
', style: Theme.of(context).textTheme.bodyText1)
- Theme.of()๋ ์กฑ๋ณด๋ฅผ ํ๋ ์
๋ ฅํ ์ ์์
- ์ด ์กฑ๋ณด์์ ๊ฐ์ฅ ๊ฐ๊น์ด ThemeData()๋ฅผ ์ฐพ์์ ๊ฐ์ ธ์์ฃผ๋ ํจ์
- ์์ ์์ ๋ bodyText1์ ์ ์ํ ์คํ์ผ์ ๊ฐ์ ธ์ฌ ์ ์์