๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ“ฑ Cross Platform/Flutter

[Flutter] ์ด๋ฏธ์ง€์™€ ํฐํŠธ ์ ์šฉํ•˜๊ธฐ (Image & Font)

by Fomagran ๐Ÿ’ป 2021. 4. 11.
728x90
๋ฐ˜์‘ํ˜•

์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค!

 

์˜ค๋Š˜์€ ์ด๋ฏธ์ง€์™€ ํฐํŠธ ์ ์šฉํ•˜๋Š” ๋ฒ•์— ๋Œ€ํ•ด์„œ ์ •๋ฆฌํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

 

(๋น„์ฅฌ์–ผ ์ŠคํŠœ๋””์˜ค ๊ธฐ์ค€์œผ๋กœ ์„ค๋ช…๋“œ๋ฆด๊ฒŒ์š”)

 

๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~


1. ์ด๋ฏธ์ง€

 

๋น„์ฅฌ์–ผ ์ŠคํŠœ๋””์˜ค์— imagesํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”.

images ์•ˆ์— ์ด๋ฏธ์ง€ ํŒŒ์ผ์„ ๋„ฃ์–ด์ฃผ์„ธ์š”.

 

 

pubspec.yaml ํŒŒ์ผ๋กœ ์ด๋™ํ•˜์…”์„œ

 

์•„๋ž˜์™€ ๊ฐ™์ด ํŒŒ์ผ ๊ฒฝ๋กœ์™€ ์ด๋ฏธ์ง€ ์ด๋ฆ„์„ ๋„ฃ์–ด์ฃผ์„ธ์š”.

  assets:
    - images/profile.png

AssetImage์— ์ด๋ฏธ์ง€ ๊ฒฝ๋กœ์™€ ์ด๋ฆ„์„ ๋„ฃ์–ด์ฃผ์„ธ์š”.

  CircleAvatar(
            radius: 50.0,
            backgroundImage: AssetImage('images/profile.png'),
          ),

 

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ด๋ฏธ์ง€๊ฐ€ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

 


2. ํฐํŠธ

 

๋จผ์ € ์•„๋ž˜ ๊ตฌ๊ธ€ ํฐํŠธ ์‚ฌ์ดํŠธ๋กœ ๊ฐ€์„œ ์›ํ•˜๋Š” ํฐํŠธ๋ฅผ ๋‹ค์šด๋ฐ›์•„์ฃผ์„ธ์š”!

 

 

 

Google Fonts

Making the web more beautiful, fast, and open through great typography

fonts.google.com

๊ทธ๋Ÿฌ๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ttfํŒŒ์ผ์ด ์žˆ์„๊ฑฐ์—์š”.

 

 

๋น„์ฅฌ์–ผ ์ŠคํŠœ๋””์˜ค๋กœ ์ด๋™ํ•ด์„œ ํด๋”๋ฅผ fonts๋กœ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค.

 

๊ทธ๋ฆฌ๊ณค ์ด fonts ํด๋” ์•ˆ์— ttfํŒŒ์ผ์„ ๋„ฃ์–ด์ฃผ์„ธ์š”.

pubspec.yaml ํŒŒ์ผ๋กœ ์ด๋™ํ•ด์ฃผ์„ธ์š”.

 

์•„๋ž˜์™€ ๊ฐ™์ด assets ๋ฐ‘์— ๋‹ค์šด๋ฐ›์€ ttf์ด๋ฆ„๊ณผ ์ฃผ์†Œ๋ฅผ ๋„ฃ์–ด์ฃผ์„ธ์š”.

 

  assets:
    - images/profile.png
    
  fonts:
    - family: Timmana
      fonts:
        - asset: fonts/Timmana-Regular.ttf
      # ...

 

์œ„์—์„œ ์ •ํ•ด์ค€ family ์ด๋ฆ„์„ ์ ์šฉํ•ด์ฃผ์„ธ์š”.

Text(
            "Fomagran",
            style: TextStyle(
                fontFamily: "Timmana",
                fontSize: 40,
                color: Colors.white,
                fontWeight: FontWeight.bold),
          ),

 

์•„๋ž˜์™€ ๊ฐ™์ด ํฐํŠธ๊ฐ€ ์ ์šฉ๋˜๋Š”๊ฑธ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€