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

[Flutter] ์˜คํ”ˆ์†Œ์Šค ํŒจํ‚ค์ง€ ์‚ฌ์šฉํ•ด๋ณด๊ธฐ(Using opensource package)

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

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

์˜ค๋Š˜์€ Flutter์—์„œ Pub์œผ๋กœ ์™ธ๋ถ€ ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

iOS๋กœ ๋”ฐ์ง€๋ฉด Pub์€ CocoaPod์ด๊ณ  ํŒจํ‚ค์ง€๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋œปํ•˜๋Š” ๊ฒƒ ๊ฐ™๋„ค์š”.

 

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


Dart packages

 

๋จผ์ € pub.dev๋ผ๋Š” ์‚ฌ์ดํŠธ๋กœ ์ด๋™ํ•ด์ฃผ์„ธ์š”.

 

์ด ์‚ฌ์ดํŠธ๋Š” ๋‹ค์–‘ํ•œ ์˜คํ”ˆ์†Œ์Šค๋“ค์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒ€์ƒ‰ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฒ•์— ๋Œ€ํ•ด ๋‚˜์™€์žˆ๋Š” ์‚ฌ์ดํŠธ์ž…๋‹ˆ๋‹ค.

 

 

 

Dart packages

Pub is the package manager for the Dart programming language, containing reusable libraries & packages for Flutter, AngularDart, and general Dart programs.

pub.dev

์ €๋Š” ์—ฌ๊ธฐ์„œ english word๋ผ๋Š” ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

enlish word๋Š” ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ์ตœ๋Œ€ 5,000 ๊ฐœ์˜ ์˜์–ด ๋‹จ์–ด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜์žˆ๋Š” ํŒจํ‚ค์ง€ ์ž…๋‹ˆ๋‹ค.

 

 

ํŒจํ‚ค์ง€๋กœ ๋“ค์–ด๊ฐ€์„œ installing์„ ๋ˆŒ๋Ÿฌ์ค๋‹ˆ๋‹ค.

 

์•„๋ž˜์™€ ๊ฐ™์ด dependencies์— ํŒจํ‚ค์ง€ ๋ฒ„์ „์ด ์ ํ˜€์žˆ์„๊ฒ๋‹ˆ๋‹ค.

 

dependencies:
  english_words: ^3.1.5

Visual Studio

 

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

 

dependencies ์•„๋ž˜์—  cupertino_icons๋ผ๊ณ  ์ ํ˜€์žˆ์„ํ…๋ฐ ๊ทธ ์•„๋ž˜์— ์œ„ ํŒจํ‚ค์ง€ dependencies๋ฅผ ๋ณต์‚ฌ์—์„œ ๋ถ™์—ฌ๋„ฃ์–ด์ค๋‹ˆ๋‹ค.

 

(ํ˜น์‹œ๋ผ๋„ ์•„๋ž˜์™€ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋œจ๋Š” ๋ถ„๋“ค์€ ๋ฒ„์ „์„ 3.1.5๋กœ ํ•ด์ฃผ์„ธ์š”!)

 

 

๊ทธ ๋‹ค์Œ ์˜ค๋ฅธ์ชฝ ๋งˆ์šฐ์Šค๋ฅผ ํด๋ฆญํ•ด์„œ Get Packages๋ฅผ ๋ˆŒ๋Ÿฌ์ค๋‹ˆ๋‹ค.

 

 

์„ฑ๊ณต์ ์œผ๋กœ ๋˜์—ˆ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ถœ๋ ฅ๋ ๊ฑฐ์—์š”.

 

 

์™ผ์ชฝํƒญ์—์„œ DEPENDENCIES๋ฅผ ๋ด๋ณด๋ฉด ์ถ”๊ฐ€ํ•œ enlish_words๋ผ๋Š” ํŒจํ‚ค์ง€๊ฐ€ ์žˆ๋Š”๊ฑธ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 


main.dart

 

mainํŒŒ์ผ๋กœ ์ด๋™ํ•ด์„œ ํ•ด๋‹น ํŒจํ‚ค์ง€๋ฅผ import ํ•ด์ค๋‹ˆ๋‹ค.

 

 

์•„๋ž˜์™€ ๊ฐ™์ด Text๋ฅผ nouns.first๋ฅผ ํ•ด์ฃผ๋ฉด ๋ช…์‚ฌ์ค‘์—์„œ ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ์ด๋Š” ์ฒซ๋ฒˆ์งธ๋กœ ๋„์šฐ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

 

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Center(child: Text(nouns.last)),
        ),
      ),
    );
  }
}

 

์•„๋ž˜์™€ ๊ฐ™์ด time์ด๋ผ๊ณ  ๋‚˜์˜ค๋„ค์š”! (time์ด ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ์ด๋Š” ๋ช…์‚ฌ์ธ๊ฐ€ ๋ณด๋„ค์š”.)

 

 

 

์˜ค๋Š˜์€ ์ด๋ ‡๊ฒŒ ํŒจํ‚ค์ง€๋ฅผ ์ด์šฉํ•ด์„œ enlish_words๋ผ๋Š” ์˜คํ”ˆ์†Œ์Šค ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

 

ํ˜น์‹œ๋ผ๋„ ํ‹€๋ฆฐ ์ ์ด ์žˆ๊ฑฐ๋‚˜ ๊ถ๊ธˆํ•˜์‹  ๋ถ€๋ถ„์ด ์žˆ์œผ๋ฉด ๋Œ“๊ธ€๋กœ ์•Œ๋ ค์ฃผ์„ธ์š”!


Reference

 

 

The Complete 2021 Flutter Development Bootcamp with Dart

Officially created in collaboration with the Google Flutter team.

www.udemy.com

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€