โ›น๏ธ ๋ผ์ดํ”„/2021 ์—ฌ๋ฆ„๋ฐฉํ•™ ๋ชจ๊ฐ์ฝ”(๊ฐœ์ธ)

[์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 1์ฃผ์ฐจ - Flutter : Quiz App

2021. 7. 7. 22:21

์˜ค๋Š˜๋ถ€ํ„ฐ Flutter๋ฅผ ๊ณต๋ถ€ํ•˜๋ ค๊ณ  ํ•œ๋‹ค.

์›๋ž˜๋Š” Spring ๊ณต๋ถ€๋ฅผ ํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ ์ด๋ฒˆ์— ์ง€๋ž€์ง€๊ต์†Œํ”„ํŠธ์—์„œ ์ธํ„ด์„ ์ง„ํ–‰ํ•˜๋Š”๋ฐ

์—ฌ๊ธฐ์„œ Flutter๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์•ฑ์„ ๊ฐœ๋ฐœํ•˜๋Š” ๊ณต๋ถ€๋ฅผ ์ง„ํ–‰ํ•˜๊ณ  ์žˆ์–ด์„œ Flutter๋ฅผ ๋”ฐ๋กœ ๊ณต๋ถ€ํ•ด์•ผํ–ˆ๋‹ค.

Flutter์™€ Spring์„ ๋™์‹œ์— ๊ณต๋ถ€ํ•˜๊ธฐ์—” ์‹œ๊ฐ„์ด ๋„ˆ๋ฌด ๋ถ€์กฑํ•ด์„œ ๊ทธ๋ƒฅ Flutter์— ์ง‘์ค‘ํ•˜๋ ค๊ณ  ํ•œ๋‹ค.

 

์ผ๋‹จ ๊ฐ•์˜๋Š” Udemy ๊ฐ•์˜๋ฅผ ์ˆ˜๊ฐ•ํ•˜๊ณ  ์žˆ๋Š”๋ฐ ์˜์–ด ๊ฐ•์˜๋ผ ์ž๋ง‰์„ ์ผœ๋‘๊ณ  ํ•˜๋Š”๋ฐ๋„ ์‚ด์ง ๋นก์„ธ๋‹ค.

์™œ ํ•œ๊ตญ ๊ฐ•์˜๋ฅผ ์ˆ˜๊ฐ•ํ•˜์ง€ ์•Š์•˜๋ƒ๊ณ  ๋ฌผ์–ด๋ณธ๋‹ค๋ฉด ๊ตญ๋‚ด ๊ฐ•์˜ ์ค‘์— Flutter ๊ฐ•์˜๊ฐ€ ๊ดœ์ฐฎ์€๊ฒŒ ์—†๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

๋˜ํ•œ ์ธํ”„๋Ÿฐ์— ๋ช‡ ๊ฐœ ๊ฐ•์˜๊ฐ€ ์žˆ๋Š”๋ฐ ๋„ˆ๋ฌด ๋น„์ŒŒ๋‹ค.

Udemy์—์„  ๊ณ ์ž‘ 14000์›... ๊ฐ•์˜ ์‹œ๊ฐ„ ์—ญ์‹œ 42์‹œ๊ฐ„์œผ๋กœ ์ƒ๋‹นํ–ˆ๊ณ  ์ปค๋ฆฌํ˜๋Ÿผ ์—ญ์‹œ ๋งˆ์Œ์— ๋“ค์—ˆ๋‹ค.

๊ธฐ๋ณธ์ ์ธ Flutter ๊ฐœ๋…๋ถ€ํ„ฐ ์•ฑ๊ฐœ๋ฐœ์„ ํ†ตํ•œ ์‹ค์Šต๊นŒ์ง€... ์ด๋ฒˆ ์—ฌ๋ฆ„๋ฐฉํ•™์„ ์•Œ์ฐจ๊ฒŒ ๋ณด๋‚ด๊ณ  ์‹ถ๋‹ค.

 

์ด๋ฒˆ์ฃผ๋Š” ๊ฐ€๋ณ๊ฒŒ ๊ทธ๋ƒฅ ์†Œ์Šค์ฝ”๋“œ๋งŒ ์˜ฌ๋ฆฌ๋ ค๊ณ  ํ•œ๋‹ค.

์‚ฌ์‹ค 1์ฃผ์ฐจ ๋•Œ ์˜ฌ๋ ธ์–ด์•ผ ํ–ˆ๋Š”๋ฐ ๋งˆ์ง€๋ง‰ 6์ฃผ์ฐจ์— ์˜ฌ๋ ธ๋‹ค... ๊ทธ๋ž˜์„œ ์ข€ ๊ท€์ฐฎ...

import 'package:flutter/material.dart';
import './quiz.dart';
import './result.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _MyAppState(); // _๋ฅผ ๋ถ™์ด๋ฉด private
  }
}

class _MyAppState extends State<MyApp> {
  var _questionIndex = 0;
  var _totalScore = 0;
  final _questions = const [
    {
      'questionText': 'Whats your favorite color?',
      'answers': [
        {'text': 'Black', 'score': 10},
        {'text': 'Red', 'score': 7},
        {'text': 'Green', 'score': 4},
        {'text': 'white', 'score': 1},
      ],
    },
    {
      'questionText': 'Whats your favorite animal?',
      'answers': [
        {'text': 'Dog', 'score': 10},
        {'text': 'Cat', 'score': 7},
        {'text': 'Lion', 'score': 4},
        {'text': 'Tiger', 'score': 1},
      ],
    },
  ];

  void _resetQuiz() {
    setState(() {
      _questionIndex = 0;
      _totalScore = 0;
    });
  }

  void _answerQuestion(int score) {
    _totalScore += score;

    setState(() {
      _questionIndex = _questionIndex + 1;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text('My first App'),
          ),
          body: _questionIndex < _questions.length
              ? Quiz(
                  answerQuestion: _answerQuestion,
                  questionIndex: _questionIndex,
                  questions: _questions)
              : Result(_totalScore, _resetQuiz)),
    );
  }
}
import 'package:flutter/material.dart';

class Question extends StatelessWidget {
  final String _questionText;

  Question(this._questionText);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      margin : EdgeInsets.all(30),
      child: Text(
        _questionText,
        style: TextStyle(fontSize: 28),
        textAlign: TextAlign.center,
      ),
    );
  }
}
import 'package:flutter/material.dart';
import './question.dart';
import './answer.dart';

class Quiz extends StatelessWidget {
  final List<Map<String, Object>> questions;
  final int questionIndex;
  final Function answerQuestion;

  Quiz(
      {required this.answerQuestion,
      required this.questions,
      required this.questionIndex}); // required๋Š” ๋ฌด์กฐ๊ฑด ์ธ์ž ๊ฐ’์ด ์žˆ์–ด์•ผํ•œ๋‹ค๋Š” ๋œป

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Question(
          questions[questionIndex]["questionText"] as String,
        ),
        ...(questions[questionIndex]["answers"] as List<Map<String, Object>>).map((answer) {
          return Answer(() => answerQuestion(answer['score']), answer['text'] as String);
        }).toList()
      ],
    );
  }
}
import 'package:flutter/material.dart';

class Result extends StatelessWidget {
  final int resultScore;
  final VoidCallback resetHandler;

  Result(this.resultScore, this.resetHandler);

  String get resultPhrase {
    var resultText = 'You did it';
    if (resultScore <= 2) {
      resultText = "You are awesome and Innocent!";
    } else if (resultScore <= 8) {
      resultText = "just good!";
    } else if (resultScore <= 14) {
      resultText = "normal";
    } else {
      resultText = "oh my god!";
    }
    return resultText;
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(children: <Widget>[
        Text(
          resultPhrase,
          style: TextStyle(fontSize: 36, fontWeight: FontWeight.bold),
          textAlign: TextAlign.center,
        ),
        TextButton(
            child: Text('Restart Quiz!'),
            style : ButtonStyle(foregroundColor: MaterialStateProperty.all(Colors.blue)),
            onPressed: resetHandler),
      ]),
    );
  }
}
์ €์ž‘์žํ‘œ์‹œ ๋น„์˜๋ฆฌ ๋ณ€๊ฒฝ๊ธˆ์ง€ (์ƒˆ์ฐฝ์—ด๋ฆผ)

'โ›น๏ธ ๋ผ์ดํ”„ > 2021 ์—ฌ๋ฆ„๋ฐฉํ•™ ๋ชจ๊ฐ์ฝ”(๊ฐœ์ธ)' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 6์ฃผ์ฐจ - Flutter : Shop App 3  (0) 2021.08.10
[์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 5์ฃผ์ฐจ - Flutter : Shop App 2  (0) 2021.08.10
[์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 4์ฃผ์ฐจ - Flutter : Shop App 1  (0) 2021.07.28
[์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 3์ฃผ์ฐจ - Flutter : Personal Expense App  (2) 2021.07.22
[์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 2์ฃผ์ฐจ - Flutter : Personal Expense App  (0) 2021.07.15
'โ›น๏ธ ๋ผ์ดํ”„/2021 ์—ฌ๋ฆ„๋ฐฉํ•™ ๋ชจ๊ฐ์ฝ”(๊ฐœ์ธ)' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
  • [์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 5์ฃผ์ฐจ - Flutter : Shop App 2
  • [์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 4์ฃผ์ฐจ - Flutter : Shop App 1
  • [์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 3์ฃผ์ฐจ - Flutter : Personal Expense App
  • [์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 2์ฃผ์ฐจ - Flutter : Personal Expense App
kodo_o
kodo_o
iOS ๊ฟ€์žผ!
kodo_o
๐ŸŽ๐Ÿ
kodo_o
์ „์ฒด
์˜ค๋Š˜
์–ด์ œ
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (149)
    • ๐Ÿ”จ ํ”„๋กœ์ ํŠธ (0)
      • TP 1 (0)
      • WhiteHCCTV (0)
      • FootPrint (0)
    • ๐Ÿ’ป ๊ฐœ๋ฐœ (63)
      • iOS (30)
      • Android (6)
      • Kotlin (4)
      • Flutter (9)
      • Node.js (5)
      • Architecture (1)
      • ์˜ค๋Š˜์˜ ์‚ฝ์งˆ (7)
      • ์—๋Ÿฌ์™€์˜ ๋™์นจ (1)
    • โœ๏ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜ (6)
      • Graph (6)
      • String (0)
      • Sort (0)
    • โœ๏ธ ์ฝ”ํ…Œ ์ค€๋น„ (44)
      • Math (1)
      • Implementation (3)
      • String (3)
      • Brute Force (5)
      • Back Tracking (7)
      • Greedy (0)
      • Dynamic Programming (13)
      • Binary Search (1)
      • DFS, BFS (5)
      • Shortest Path (2)
      • Two Pointer (4)
      • MST (0)
    • ๐Ÿ“š CS (6)
      • Operating System (6)
    • โ›น๏ธ ๋ผ์ดํ”„ (30)
      • 2020 ๊ฒจ์šธ๋ฐฉํ•™ ๋ชจ๊ฐ์ฝ”(๊ฐœ์ธ) (12)
      • 2021 ์—ฌ๋ฆ„๋ฐฉํ•™ ๋ชจ๊ฐ์ฝ”(๊ฐœ์ธ) (6)
      • ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ (1)
      • ํšŒ๊ณ  (10)

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • ํ™ˆ
  • ๊นƒํ—ˆ๋ธŒ

์ธ๊ธฐ ๊ธ€

์ตœ๊ทผ ๊ธ€

์ตœ๊ทผ ๋Œ“๊ธ€

hELLO ยท Designed By ์ •์ƒ์šฐ.
kodo_o
[์ฝ”๋…ํ•˜๊ตฌ๋งŒ 2] 1์ฃผ์ฐจ - Flutter : Quiz App
์ƒ๋‹จ์œผ๋กœ

ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”

๋‹จ์ถ•ํ‚ค

๋‚ด ๋ธ”๋กœ๊ทธ

๋‚ด ๋ธ”๋กœ๊ทธ - ๊ด€๋ฆฌ์ž ํ™ˆ ์ „ํ™˜
Q
Q
์ƒˆ ๊ธ€ ์“ฐ๊ธฐ
W
W

๋ธ”๋กœ๊ทธ ๊ฒŒ์‹œ๊ธ€

๊ธ€ ์ˆ˜์ • (๊ถŒํ•œ ์žˆ๋Š” ๊ฒฝ์šฐ)
E
E
๋Œ“๊ธ€ ์˜์—ญ์œผ๋กœ ์ด๋™
C
C

๋ชจ๋“  ์˜์—ญ

์ด ํŽ˜์ด์ง€์˜ URL ๋ณต์‚ฌ
S
S
๋งจ ์œ„๋กœ ์ด๋™
T
T
ํ‹ฐ์Šคํ† ๋ฆฌ ํ™ˆ ์ด๋™
H
H
๋‹จ์ถ•ํ‚ค ์•ˆ๋‚ด
Shift + /
โ‡ง + /

* ๋‹จ์ถ•ํ‚ค๋Š” ํ•œ๊ธ€/์˜๋ฌธ ๋Œ€์†Œ๋ฌธ์ž๋กœ ์ด์šฉ ๊ฐ€๋Šฅํ•˜๋ฉฐ, ํ‹ฐ์Šคํ† ๋ฆฌ ๊ธฐ๋ณธ ๋„๋ฉ”์ธ์—์„œ๋งŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.