๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
APP/FLUTTER

[Flutter #3] Xylophone & Quizzler

by mingzoo 2021. 1. 5.

๐Ÿ“š์ด ํฌ์ŠคํŠธ๋Š” ์•ˆ์ ค๋ผ์˜ ์œ ๋ฐ๋ฏธ ํ”Œ๋Ÿฌํ„ฐ๊ฐ•์˜๋ฅผ ๋“ฃ๊ณ  ์ œ๊ฐ€ ์ฐพ์•„๋ณธ ๋‚ด์šฉ์„ ๋ฐ”ํƒ•์œผ๋กœ ์ž‘์„ฑํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค! ๐Ÿ“š

์˜ˆ์ „์— ๊ณต๋ถ€ํ•˜๋ฉด์„œ ๋…ธ์…˜์— ์ •๋ฆฌํ•ด๋†“์•˜๋˜๊ฑธ ๋‹ค์‹œ ๊ฐ€์ ธ์™€์„œ ์กฐ๊ธˆ ๋’ค์ฃฝ๋ฐ•์ฃฝํ•ด ๋ณด์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

๊ฐ•์˜์—์„œ ์“ฐ์˜€๋˜ ๊ฐœ๋… ์œ„์ฃผ์˜ ์งค๋ง‰์งค๋ง‰ํ•œ ์„ค๋ช…์ž…๋‹ˆ๋‹ค. ๐Ÿ˜“

Xylophone : Flutter Package ์‚ฌ์šฉ๋ฒ•

Xylophone ํŒŒํŠธ์—์„œ๋Š” Flutter Package๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์œ„์ฃผ๋กœ ๋งŒ๋“ค์–ด์กŒ๋‹ค.

Flutter Packages - text, sound, font ๋‹ค ๋„ฃ๋Š” ๋ฐฉ์‹ ๋™์ผํ•˜๋‹ค

 

https://pub.dev/ ์—์„œ ์›ํ•˜๋Š” ํŒจํ‚ค์ง€๋ฅผ ๋‹ค์šด๋ฐ›๊ธฐ

๋‹ค์šด๋กœ๋“œ ์‚ฌ์ดํŠธ์— example๊ณผ ์„ค๋ช… ๋‹ค ์กด์žฌํ•˜๋‹ˆ๊นŒ ๊ทธ ์„ค๋ช…๋ณด๊ณ  ์•„๋ž˜์™€ ๊ฐ™์ด ์ฝ”๋“œ์— ์ž‘์„ฑํ•˜๋ฉด๋œ๋‹ค.

dependencies:
    english_words : ^ 3.1.5
//๋ฒ„์ „์— ๋Œ€ํ•ด์„œ- ๋‹ค์šด๋ฐ›์„ ๋•Œ ์˜†์— ์จ์žˆ๋Š” ๋ฒ„์ ผ์„ ์“ฐ๋Š” ๊ฒŒ ์ œ์ผ ์•ˆ์ „ํ•จ
//์ฒซ๋ฒˆ์งธ ์ˆซ์ž๊ฐ€ ๋ฐ”๋€Œ๋ฉด ์•ฑ์— crashํ•˜๋Š” ์ผ์„ ํ–ˆ์„ ์ˆ˜๋„ ์žˆ๋‹ค.
//๋‹ค์šด๋ฐ›์€ ํŒจํ‚ค์ง€์˜ ์†Œ์Šค๋ฅผ ๋ณด๊ณ  ์‚ฌ์šฉํ•˜๊ธฐ

main.dart์—์„œ
import ' package:english word 3.1.5';
^ : caret symbol

 

๋ฒ„ํŠผ์— ์†Œ๋ฆฌ ์ง‘์–ด๋„ฃ๊ธฐ

child : FlatButton(onPressed: () {
              final player = AudioCache();
              player.play('note1.wav');
            }, child: Text('Click Me'))),

 

ํ•จ์ˆ˜๋งŒ๋“ค๊ธฐ

๋„ˆ๋ฌด ๋˜‘๊ฐ™์€ ์ฝ”๋“œ๊ฐ€ ๋ฐ˜๋ณต๋˜๋ฉด ์ด์˜๊ณ  ๊ฐ„๊ฒฐํ•œ ์ฝ”๋“œ๋ฅผ ์œ„ํ•ด ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค๊ธฐ!

Expended Widget : ๊ธธ๊ฒŒ ํ™•์žฅ์‹œํ‚ค๊ธฐ

CrossAxisAlignment : CrossAxisAlignment.stretch  =>  ์ญ‰ ์ŠคํŠธ๋ ˆ์น˜ ์‹œํ‚ค๊ธฐ

Dart Arrow Function

ํ™”์‚ดํ‘œ ํ•จ์ˆ˜๋Š” ํ•œ ์ค„๋กœ ํ‘œํ˜„ ๊ฐ€๋Šฅ

int add(){
      return 5+2;
}

//ํ™”์‚ดํ‘œํ•จ์ˆ˜๋กœ ๋ฐ”๊พธ๋ฉด
int add() => 5+2;

 


 

Quizzler : Classes, objects

Quizzler ํŒŒํŠธ์—์„œ๋Š” class์™€ object๋ฅผ ์ค‘์ ์ ์œผ๋กœ ๋‹ค๋ฃจ์—ˆ๋‹ค.

 

์ฝ”๋“œ์ค‘์— //TODO:_______________๋ผ๊ณ  ์ž‘์„ฑํ•˜๋ฉด ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค์—์„œ ๋ฐ‘์— TODO๋ผ๊ณ  ์“ฐ์—ฌ์žˆ๋Š” ๊ณณ์„ ๋ˆ„๋ฅธ๋‹ค๋ฉด ๋ฏธ๋ฆฌ ์ž‘์„ฑํ•ด๋†“์€ TODO๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 

  • SafeArea/Padding/Center => 1๊ฐœ์˜ child
  • column => child๋ฅผ ๋ฆฌ์ŠคํŠธ๋กœ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Œ

List

List<datatype> ๋ฆฌ์ŠคํŠธ์ด๋ฆ„ = [];

 

ํ”Œ๋Ÿฌํ„ฐ ํ™œ์šฉ ํŒ!

  • VCS๋ฉ”๋‰ด ⇒ Local History ⇒ show History๋ฅผ ํ•˜๋ฉด ์ž‘์„ฑ์ž๊ฐ€ ์ˆ˜์ •ํ–ˆ๋˜ ์ฝ”๋“œ๋“ค์„ ์ƒ์„ธํ•˜๊ฒŒ ๋ณผ ์ˆ˜ ์žˆ์Œ
  • ๋งŒ์•ฝ, ๋‚ด๊ฐ€ ์„ค์ •ํ•œ ๋‹จ์–ด์— ๊ณ„์† ์ค„์ด ์ณ์ง„๋‹ค! ⇒์šฐํด๋ฆญ →Save'๋‹จ์–ด'to project level dictionary
  • (์ž‘์€๋”ฐ์˜ดํ‘œ)๋ฅผ ์ถœ๋ ฅํ•˜๊ณ  ์‹ถ์œผ๋ฉด ์ถœ๋ ฅํ•˜๋ ค๋Š” ์ž‘์€๋”ฐ์˜ดํ‘œ์•ˆ์— /๋ถ™์ด๊ธฐ
Text('Minjoo/'s House'),

 

  • Flutter Inspector→x๋ชจ์–‘์˜ Locate ๋ฒ„ํŠผ ๋ˆ„๋ฅด๊ธฐ ⇒์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ์— ๋„์›Œ์ ธ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ๋‚˜ ์š”์†Œ๋“ค์ด ์ฝ”๋“œ ์ค‘์— ์–ด๋””์— ์žˆ๋Š”์ง€ ์•Œ๋ ค์คŒ

 

Class

libํŒŒ์ผ ์šฐํด๋ฆญ→ New Dart File → 'ํŒŒ์ผ์ด๋ฆ„' ๊ธด์ฝ”๋“œ๋ฅผ ๊ฐ„๋žตํ•˜๊ฒŒ ๋งŒ๋“ค๊ธฐ

Object Oriented Programming(OOP)

Abstraction ์ถ”์ƒํ™”

seperating job ๊ฐ„๋žตํ•˜๊ฒŒ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด์„œ ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์„œ ํด๋ž˜์Šค๋กœ ์จ์„œ ๋ฉ”์ธ์—์„œ ๋” ๊ฐ„๋žตํ•˜๊ฒŒ ํ‘œํ˜„ํ•˜๊ฒŒ ํ•จ

Encapsulation ์บก์Šํ™”

private์œผ๋กœ ๋ณ€์ˆ˜๋ฅผ ๋‚˜ํƒ€๋‚ด๋ ค๋ฉด questionNumber๊ฐ€ ์•„๋‹Œ _questionNumber๋กœ ์„ ์–ธํ•˜๊ณ  ์‚ฌ์šฉ

Inheritation ์ƒ์†

class ElectricCar extends Car{};
//์ƒ์†์„ ํ•˜๋ ค๋ฉด extends๋ฅผ ์‚ฌ์šฉ
๋ถ€๋ชจํด๋ž˜์Šค : Car
์ž์‹ํด๋ž˜์Šค : ElectricCar
Car์— ์žˆ๋Š” ๋‚ด์šฉ์„ ElectricCar๋กœ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ

Polymorphism ๋‹คํ˜•์„ฑ

์ƒ์† ๋ฐ›์€ ๊ฑธ ์ž์‹ํด๋ž˜์Šค์— ๋งž๊ฒŒ ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์„ ๋œปํ•˜๋Š”๋ฐ
class ElectricCar extends Car{
   @override
   void drive(){
      print('wheel turns');
   }
   super.drive(); //๋ถ€๋ชจํด๋ž˜์Šค์˜ ๋“œ๋ผ์ด๋ธŒํ•จ์ˆ˜ ์‹คํ–‰
}
class Human{
// Property
double Height;
int age = 0;

//Constructor
Human({double StartingHeight}){
height = startingHeight;
}

//method
void grow(int numofYears){
age = age + numofYears;
}
}

 

This

  1. ๊ฐ์ฒด์ž์‹ ์˜ ์ฃผ์†Œ๋ฅผ ๋ฆฌํ„ดํ•  ๋•Œ
  2. ๊ฐ์ฒด ์ž์‹ ์˜ ์ฐธ์กฐ์ž๋ฅผ ๋ฆฌํ„ดํ•˜๊ณ ์ž ํ•  ๋•Œ
  3. ๊ฐ์ฒด ์ž์‹ ์„ ๋ณต์‚ฌํ•˜์—ฌ ๋ฆฌํ„ดํ•˜๊ณ ์ž ํ•  ๋•Œ
  4. ๋™์ผ ์ด๋ฆ„์˜ ๋ณ€์ˆ˜์™€ ๊ตฌ๋ถ„ํ•˜๊ธฐ์œ„ํ•ด
  5. ๊ฐ์ฒด ์žฌ๋ถ€์—์„œ ์ž์‹ ์˜ ์ฃผ์†Œ๊ฐ’์ด ์‚ฌ์šฉ๋  ๋•Œ
728x90

'APP > FLUTTER' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

FLUTTER #2 Dicee & Dart  (0) 2020.09.11
FLUTTER #4 BMI Calculator  (0) 2020.01.19
FLUTTER #1 I_am_rich  (0) 2020.01.18