๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ“ฑ|APP DEV/Flutter

[Flutter] Flutter์—์„œ FontAwesome ์•„์ด์ฝ˜ ์‚ฌ์šฉํ•˜๊ธฐ

by KASSID 2023. 1. 23.

๋ชฉ์ฐจ

    728x90

    ํ‰์†Œ ์ •๋ง ์• ์šฉํ•˜๋Š” ์•„์ด์ฝ˜ ์ œ๊ณต ์‚ฌ์ดํŠธ์ธ FontAwesome!

    https://fontawesome.com/

     

    Flutterํ™˜๊ฒฝ์—์„œ ์•„์ด์ฝ˜ ์ ์šฉ ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด์•˜๋‹ค.

     

    ๋ฌผ๋ก  ๊ธฐ๋ณธ์ ์œผ๋กœ Material/Cupetino์—์„œ ์ง€์›ํ•ด์ฃผ๋Š” ์•„์ด์ฝ˜๋„ ์žˆ์ง€๋งŒ

    ์ƒํ™ฉ์— ๋งž๊ฒŒ ๋” ๋‹ค์–‘ํ•œ ์•„์ด์ฝ˜์„ ํ™œ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ ์‚ฌ์šฉํ•œ๋‹ค.

     

    font_awsome_flutter ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

    https://pub.dev/packages/font_awesome_flutter/install

     

    font_awesome_flutter | Flutter Package

    The Font Awesome Icon pack available as Flutter Icons. Provides 1600 additional icons to use in your apps.

    pub.dev

     

    ์œ„์˜ ๋งํฌ์—์„œ ์ž์„ธํžˆ ์•Œ์•„๋ณผ ์ˆ˜ ์žˆ๋‹ค.

     

    1. pubspec.yaml ์ˆ˜์ •ํ•˜๊ธฐ

    dependencies:
      font_awesome_flutter: ^10.3.0

    ์œ„์˜ ํ•ญ๋ชฉ์„ ์ˆ˜์ •ํ•œ ๋’ค ''' flutter pub get ''' ์„ ์ด์šฉํ•ด ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ๋ฐ˜์˜ํ•œ๋‹ค.

     

    2. dartํŒŒ์ผ์— ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ import

    import 'package:font_awesome_flutter/font_awesome_flutter.dart';

    ์œ„์˜ ์ฝ”๋“œ๋ฅผ dartํŒŒ์ผ์— ๋ถ™์—ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ importํ•œ๋‹ค.

     

    3. ์•„์ด์ฝ˜ ์‚ฝ์ž…

    FaIcon(FontAwesomeIcons.์•„์ด์ฝ˜๋ช…)

     

     

    ํ•˜๋‚˜์˜ ์˜ˆ์‹œ ์ฝ”๋“œ!

    import 'package:font_awesome_flutter/font_awesome_flutter.dart';
    
    class MyWidget extends StatelessWidget {
      Widget build(BuildContext context) {
        return IconButton(
          // Use the FaIcon Widget + FontAwesomeIcons class for the IconData
          icon: FaIcon(FontAwesomeIcons.gamepad), 
          onPressed: () { print("Pressed"); }
         );
      }
    }

     

    ๋Œ“๊ธ€