์ค๋๋ถํฐ 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 |