๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Mobile/Flutter

[Flutter] Write your first Flutter app, part 1

๋ฐ˜์‘ํ˜•

 

์ถœ์ฒ˜

https://docs.flutter.dev/get-started/codelab

 

Write your first Flutter app, part 1

How to write a web-based app in Flutter.

docs.flutter.dev

 

 

 

 

 

  • ์Šคํƒ€ํŠธ์—… ํšŒ์‚ฌ์— ์ œ์•ˆ๋œ ์ด๋ฆ„์„ ์ƒ์„ฑํ•˜๋Š” ๊ฐ„๋‹จํ•œ ์•ฑ ๊ตฌํ˜„
  • ์‚ฌ์šฉ์ž๋Š” ์ด๋ฆ„ ์„ ํƒ, ์ทจ์†Œ, ๊ฐ€์žฅ ์ข‹์€ ์ด๋ฆ„ ์ €์žฅ ๊ฐ€๋Šฅ
  • ์ฝ”๋“œ๋Š” ํ•œ ๋ฒˆ์— 10๊ฐœ์˜ ์ด๋ฆ„์„ ๋Š๋ฆฌ๊ฒŒ ์ƒ์„ฑํ•จ
  • ์‚ฌ์šฉ์ž๊ฐ€ ์Šคํฌ๋กค ํ•˜๋ฉด ๋” ๋งŽ์€ ์ด๋ฆ„์ด ์ƒ์„ฑ๋จ
  • ์Šคํฌ๋กค ์ œํ•œ ์—†์Œ

 

Part 1 ์—์„œ ๋ฐฐ์šธ ๋‚ด์šฉ

  • iOS, Android, ๋ฐ์Šคํฌํ†ฑ(์˜ˆ: Windows) ๋ฐ ์›น์—์„œ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ณด์ด๋Š” Flutter ์•ฑ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•
  • Flutter ์•ฑ์˜ ๊ธฐ๋ณธ ๊ตฌ์กฐ
  • ๊ธฐ๋Šฅ ํ™•์žฅ์„ ์œ„ํ•œ ํŒจํ‚ค์ง€ ์ฐพ๊ธฐ ๋ฐ ์‚ฌ์šฉ
  • ๋” ๋น ๋ฅธ ๊ฐœ๋ฐœ ์ฃผ๊ธฐ๋ฅผ ์œ„ํ•ด ํ•ซ ๋ฆฌ๋กœ๋“œ ์‚ฌ์šฉ
  • stateful widget ๊ตฌํ˜„ํ•˜๋Š” ๋ฐฉ๋ฒ•
  • ๋ฌดํ•œํžˆ ๋Š๋ฆฌ๊ฒŒ ๋กœ๋“œ๋œ ๋ชฉ๋ก์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•
์ด ์ฝ”๋“œ๋žฉ์˜ 2๋ถ€์—์„œ๋Š” ๋Œ€ํ™”ํ˜• ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ณ  ์•ฑ์˜ ํ…Œ๋งˆ๋ฅผ ์ˆ˜์ •ํ•˜๋ฉฐ ์ƒˆ ํ™”๋ฉด(Flutter์—์„œ๋Š” a route ๋ผ๊ณ  ํ•จ)์œผ๋กœ ์ด๋™ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

 

์‚ฌ์šฉํ•  ํ•ญ๋ชฉ

์ด ์‹ค์Šต์„ ์™„๋ฃŒํ•˜๋ ค๋ฉด Flutter SDK์™€ ํŽธ์ง‘๊ธฐ๋ผ๋Š” ๋‘ ๊ฐ€์ง€ ์†Œํ”„ํŠธ์›จ์–ด๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด Codelab์€ Android Studio๋ฅผ ๊ฐ€์ •ํ•˜์ง€๋งŒ ์„ ํ˜ธํ•˜๋Š” ํŽธ์ง‘๊ธฐ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ ๊ธฐ๊ธฐ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ด ์ฝ”๋“œ๋žฉ์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ์ปดํ“จํ„ฐ์— ์—ฐ๊ฒฐ๋˜๊ณ  ๊ฐœ๋ฐœ์ž ๋ชจ๋“œ๋กœ ์„ค์ •๋œ ๋ฌผ๋ฆฌ์  ์žฅ์น˜(Android ๋˜๋Š” iOS)
  • iOS ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ(Xcode ๋„๊ตฌ ์„ค์น˜ ํ•„์š”)
  • Android ์—๋ฎฌ๋ ˆ์ดํ„ฐ(Android Studio์—์„œ ์„ค์ • ํ•„์š”)
  • ๋ธŒ๋ผ์šฐ์ €(๋””๋ฒ„๊น…์„ ์œ„ํ•ด์„œ๋Š” Chrome์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค)
  • Windows, Linux ๋˜๋Š” macOS ๋ฐ์Šคํฌํƒ‘ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜

์—ฌ๋Ÿฌ๋ถ„์ด ๋งŒ๋“œ๋Š” ๋ชจ๋“  Flutter ์•ฑ์€ ์›น์šฉ์œผ๋กœ๋„ ์ปดํŒŒ์ผ๋ฉ๋‹ˆ๋‹ค. ์žฅ์น˜ ํ’€๋‹ค์šด ์•„๋ž˜์˜ IDE ๋˜๋Š” flutter ์žฅ์น˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” command line์—์„œ ์ด์ œ Chrome ๋ฐ ์›น ์„œ๋ฒ„๊ฐ€ ๋‚˜์—ด๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Chrome ๊ธฐ๊ธฐ๋Š” ์ž๋™์œผ๋กœ Chrome์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. ์›น ์„œ๋ฒ„๋Š” ๋ชจ๋“  ๋ธŒ๋ผ์šฐ์ €์—์„œ ์•ฑ์„ ๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋„๋ก ์•ฑ์„ ํ˜ธ์ŠคํŒ…ํ•˜๋Š” ์„œ๋ฒ„๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. DevTools๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ฐœ๋ฐœ ์ค‘์—๋Š” Chrome ๊ธฐ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ , ๋‹ค๋ฅธ ๋ธŒ๋ผ์šฐ์ €์—์„œ ํ…Œ์ŠคํŠธํ•  ๋•Œ๋Š” ์›น ์„œ๋ฒ„๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Flutter๋กœ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋นŒ๋“œ ๋ฐ ์›น์—์„œ ์ฒซ Flutter ์•ฑ ์ž‘์„ฑ์„ ์ฐธ์กฐํ•˜์„ธ์š”.

๋˜ํ•œ Flutter ์•ฑ์€ ๋ฐ์Šคํฌํ†ฑ์šฉ์œผ๋กœ ์ปดํŒŒ์ผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Windows(๋ฐ์Šคํฌํ†ฑ) ๋˜๋Š” flutter ์žฅ์น˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” command line๊ณผ ๊ฐ™์€ ์žฅ์น˜ ์•„๋ž˜์˜ IDE์— ๋‚˜์—ด๋œ ์šด์˜ ์ฒด์ œ๋ฅผ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ์Šคํฌํ†ฑ์šฉ ์•ฑ ๋นŒ๋“œ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ Flutter ๋ฐ์Šคํฌํ†ฑ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ž‘์„ฑ์„ ์ฐธ์กฐํ•˜์„ธ์š”.

 

Step 1: Create the starter Flutter app

Dart ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š” lib/main.dart๋ฅผ ์ฃผ๋กœ ํŽธ์ง‘ํ•  ๊ฒƒ์ด๋‹ค.

ํ™”๋ฉด ์ค‘์•™์— "Hello World"๊ฐ€ ํ‘œ์‹œ๋˜๋Š” ์ฝ”๋“œ์ด๋‹ค.

 

See the Pen Untitled by jenyang2 (@jenyang2) on CodePen.

 

 

 Tip: When pasting code into your app, indentation can become skewed. You can fix this with the following Flutter tools:

  • Android Studio and IntelliJ IDEA: Right-click the code and select Reformat Code with dartfmt.
  • VS Code: Right-click and select Format Document.
  • Terminal: Run flutter format <filename>.

 

Observations

  • ์ด ์˜ˆ์ œ์—์„œ๋Š” Material ์•ฑ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๋จธํ‹ฐ๋ฆฌ์–ผ์€ ๋ชจ๋ฐ”์ผ๊ณผ ์›น์—์„œ ํ‘œ์ค€์ด ๋˜๋Š” ์‹œ๊ฐ ๋””์ž์ธ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. Flutter๋Š” ํ’๋ถ€ํ•œ Material ์œ„์ ฏ ์„ธํŠธ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. pubspec.yaml ํŒŒ์ผ์˜ flutter ์„น์…˜์— uses-material-design: true ํ•ญ๋ชฉ์ด ์žˆ๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ฏธ๋ฆฌ ์ •์˜๋œ ์•„์ด์ฝ˜ ์„ธํŠธ์™€ ๊ฐ™์€ ๋จธํ‹ฐ๋ฆฌ์–ผ์˜ ๋” ๋งŽ์€ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์•ฑ์€ ์•ฑ ์ž์ฒด๋ฅผ ์œ„์ ฏ์œผ๋กœ ๋งŒ๋“œ๋Š” StatelessWidget์„ ํ™•์žฅํ•ฉ๋‹ˆ๋‹ค. Flutter์—์„œ๋Š” ์ •๋ ฌ, ํŒจ๋”ฉ ๋ฐ ๋ ˆ์ด์•„์›ƒ์„ ํฌํ•จํ•˜์—ฌ ๊ฑฐ์˜ ๋ชจ๋“  ๊ฒƒ์ด ์œ„์ ฏ์ž…๋‹ˆ๋‹ค.
  • Material ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ Scaffold ์œ„์ ฏ์€ ๊ธฐ๋ณธ ์•ฑ ๋ฐ”์™€ ํ™ˆ ํ™”๋ฉด์˜ ์œ„์ ฏ ํŠธ๋ฆฌ๋ฅผ ๋ณด์œ ํ•˜๋Š” ๋ฐ”๋”” ์†์„ฑ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์œ„์ ฏ ํ•˜์œ„ ํŠธ๋ฆฌ๋Š” ๋งค์šฐ ๋ณต์žกํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์œ„์ ฏ์˜ ์ฃผ์š” ์ž‘์—…์€ ๋‹ค๋ฅธ ํ•˜์œ„ ์ˆ˜์ค€ ์œ„์ ฏ๊ณผ ๊ด€๋ จํ•˜์—ฌ ์œ„์ ฏ์„ ํ‘œ์‹œํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•˜๋Š” build() ๋ฉ”์„œ๋“œ๋ฅผ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
  • ์ด ์˜ˆ์ œ์˜ ๋ณธ๋ฌธ์€ Text ์ž์‹ ์œ„์ ฏ์„ ํฌํ•จํ•˜๋Š” Center ์œ„์ ฏ์œผ๋กœ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค. Center ์œ„์ ฏ์€ ์œ„์ ฏ ํ•˜์œ„ ํŠธ๋ฆฌ๋ฅผ ํ™”๋ฉด ์ค‘์•™์— ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.

 

Step 2: Use an external package

์˜คํ”ˆ์†Œ์Šค ํŒจํ‚ค์ง€ english_words ๋ฅผ ์‚ฌ์šฉํ•ด๋ณด์ž!

* ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ์ˆ˜์ฒœ ๊ฐœ์˜ ์˜์–ด ๋‹จ์–ด์™€ ๋ช‡ ๊ฐ€์ง€ ์œ ํ‹ธ๋ฆฌํ‹ฐ ๊ธฐ๋Šฅ์ด ํฌํ•จ๋˜์–ด ์žˆ์Œ

 

 

pub.dev  ์—์„œ english_words ์™€

 ๋‹ค๋ฅธ

๋‹ค์–‘ํ•œ ์˜คํ”ˆ์†Œ์Šค ํŒจํ‚ค์ง€๋“ค์„ ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค

  1. english_words ํŒจํ‚ค์ง€๋ฅผ ํ”„๋กœ์ ํŠธ์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ถ”๊ฐ€ํ•˜์ž.
$ flutter pub add english_words
Resolving dependencies...
+ english_words 4.0.0
  path 1.8.0 (1.8.1 available)
  source_span 1.8.1 (1.8.2 available)
  test_api 0.4.3 (0.4.9 available)
Downloading english_words 4.0.0...
Changed 1 dependency!

pubspec.yaml ํŒŒ์ผ์€ ํ”Œ๋Ÿฌํ„ฐ ์•ฑ์—์„œ assets๊ณผ dependencies๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค.

pubspec.yaml ์—์„œ english_words dependency๊ฐ€ ์ถ”๊ฐ€ ๋œ ๊ฒƒ์„ ๋ณด๊ฒŒ ๋  ๊ฒƒ์ด๋‹ค

 

2. Android Studio์—์„œ pubspec.yaml ํŒŒ์ผ์„ ๋ณด๋Š” ๋™์•ˆ Pub get ์„ ํด๋ฆญ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ํŒจํ‚ค์ง€๋ฅผ ํ”„๋กœ์ ํŠธ๋กœ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค. ์ฝ˜์†”์— ๋‹ค์Œ์ด ํ‘œ์‹œ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

$ flutter pub get
Running "flutter pub get" in startup_namer...
Process finished with exit code 0

 

Pub get ์„ ์ˆ˜ํ–‰ ํ•˜๋ฉด ํ”„๋กœ์ ํŠธ์— ๊ฐ€์ ธ์˜จ ๋ชจ๋“  ํŒจํ‚ค์ง€ ๋ชฉ๋ก๊ณผ ํ•ด๋‹น ๋ฒ„์ „ ๋ฒˆํ˜ธ๊ฐ€ ํฌํ•จ๋œ pubspec.lock ํŒŒ์ผ์ด ์ž๋™ ์ƒ์„ฑ ๋ฉ๋‹ˆ๋‹ค.

 

3. lib/main.dart, import the new package:

import 'package:english_words/english_words.dart';

 

4. "Hello World" ๋ฌธ์ž์—ด์„ ์‚ฌ์šฉํ•˜๋Š” ๋Œ€์‹   English words package๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ…์ŠคํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

 

// Copyright 2018 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:english_words/english_words.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
  	final wordPair = WordPair.random();
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Welcome to Flutter'),
        ),
        body: Center(
          child: child: Text(wordPair.asPascalCase),
        ),
      ),
    );
  }
}

 

์ฐธ๊ณ :
 "Pascal case"("upper camel case"๋ผ๊ณ ๋„ ํ•จ)๋Š” ์ฒซ ๋ฒˆ์งธ ๋‹จ์–ด๋ฅผ ํฌํ•จํ•˜์—ฌ ๋ฌธ์ž์—ด์˜ ๊ฐ ๋‹จ์–ด๊ฐ€ ๋Œ€๋ฌธ์ž๋กœ ์‹œ์ž‘ํ•จ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ "uppercamelcase"๋Š” "UpperCamelCase"๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.

Pascal case = upper camel case

uppercamelcase -> UpperCamelCase

 

 

5. hot reload ํด๋ฆญ or save ํ•  ๋•Œ ๋งˆ๋‹ค ๋ฌด์ž‘์œ„๋กœ ์„ ํƒ๋œ ๋‹ค๋ฅธ ๋‹จ์–ด ์Œ์ด ํ‘œ์‹œ๋˜์–ด์•ผ ํ•œ๋‹ค.

๋‹จ์–ด ์Œ์ด build ๋ฉ”์†Œ๋“œ (๋ Œ๋”๋ง์ด ํ•„์š” ํ•  ๋•Œ ์‹คํ–‰ or Flutter Inspector์—์„œ Platform์„ ํ† ๊ธ€ํ•  ๋•Œ ์‹คํ–‰) ๋‚ด์—์„œ ์ƒ์„ฑ๋˜๊ธฐ ๋•Œ๋ฌธ์—

 

See the Pen Flutter2 by jenyang2 (@jenyang2) on CodePen.

 

Step 3: Add a Stateful widget

Stateless ์œ„์ ฏ์€ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์ฆ‰, ์†์„ฑ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†์œผ๋ฉฐ ๋ชจ๋“  ๊ฐ’์ด final

 

 

Stateful  ์œ„์ ฏ์€ ์œ„์ ฏ์˜ ์ˆ˜๋ช… ๋™์•ˆ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๋Š” ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•ฉ๋‹ˆ๋‹ค. Stateful ์œ„์ ฏ์„ ๊ตฌํ˜„ํ•˜๋ ค๋ฉด ์ตœ์†Œํ•œ ๋‘ ๊ฐœ์˜ ํด๋ž˜์Šค๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

1) StatefulWidget class - ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑ

2) State class. StatefulWidget class๋Š” ์ž์ฒด๋กœ ๋ถˆ๋ณ€์ด๋ฉฐ ๋ฒ„๋ฆฌ๊ณ  ๋‹ค์‹œ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์ง€๋งŒ Stateํด๋ž˜์Šค๋Š” ์œ„์ ฏ์˜ ์ˆ˜๋ช… ๋™์•ˆ ์ง€์†๋ฉ๋‹ˆ๋‹ค.

 

Stateful ์œ„์ ฏ ์„ ์ถ”๊ฐ€ํ•˜์ž : RandomWords / State class : _RandomWordsState

๊ทธ๋Ÿฐ ๋‹ค์Œ RandomWords๋ฅผ ๊ธฐ์กด MyApp stateless widget ๋‚ด์—์„œ ์ž์‹์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

 

1. stateful widget ์— ๋Œ€ํ•œ boilerplate code ์ƒ์„ฑ

stful ์„ ์น˜๋ฉด  Stateful ์œ„์ ฏ ์„ ์ƒ์„ฑํ•  ๊ฒƒ์ธ์ง€ ๋ฌป์Šต๋‹ˆ๋‹ค. Return ํ‚ค ๋ฅผ ๋ˆŒ๋Ÿฌ ์ˆ˜๋ฝํ•ฉ๋‹ˆ๋‹ค. 

๋‘ ํด๋ž˜์Šค์— ๋Œ€ํ•œ boilerplate code๊ฐ€ ๋‚˜ํƒ€๋‚˜๊ณ  ์ปค์„œ๋Š” stateful widget์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋Š” ์œ„์น˜์— ์žˆ์Šต๋‹ˆ๋‹ค.

 

2. ์œ„์ ฏ์ด๋ฆ„์œผ๋กœ RandomWords ์ž…๋ ฅ

RandomWords ์œ„์ ฏ ์€ State ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ ์™ธ์— ๋‹ค๋ฅธ ์ž‘์—…์„ ๊ฑฐ์˜ ์ˆ˜ํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

 

RandomWords๋ฅผ stateful widget ์ด๋ฆ„์œผ๋กœ ์ž…๋ ฅ ํ•˜๋ฉด IDE์—์„œ ์ž๋™์œผ๋กœ State ํด๋ž˜์Šค๋ฅผ ์—…๋ฐ์ดํŠธํ•˜์—ฌ ์ด๋ฆ„์„ _RandomWordsState๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค . ๊ธฐ๋ณธ์ ์œผ๋กœ State ํด๋ž˜์Šค ์ด๋ฆ„์—๋Š” ์–ธ๋”๋ฐ”๊ฐ€ ์ ‘๋‘์‚ฌ๋กœ ๋ถ™์Šต๋‹ˆ๋‹ค. ์‹๋ณ„์ž ์ ‘๋‘์‚ฌ์— ๋ฐ‘์ค„ ์„ ์ถ”๊ฐ€ํ•˜๋ฉด Dart ์–ธ์–ด์—์„œ ๊ฐœ์ธ์ •๋ณด ๊ฐ€ ๋ณดํ˜ธ๋˜๋ฉฐ State ๊ฐ์ฒด ์— ๊ถŒ์žฅ๋˜๋Š” ๋ชจ๋ฒ” ์‚ฌ๋ก€์ž…๋‹ˆ๋‹ค . 

 

IDE๋Š” ๋˜ํ•œ ์ž๋™์œผ๋กœ ์ƒํƒœ ํด๋ž˜์Šค๋ฅผ ํ™•์žฅํ•˜์—ฌ ์—…๋ฐ์ดํŠธํ•˜์—ฌ ๋‹ค์Œ ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋„๋ก ํŠน์ˆ˜ํ™” ๋œ ์ผ๋ฐ˜ ํด๋ž˜์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Œ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.

 

 

class RandomWords extends StatefulWidget {
  const RandomWords({ Key? key }) : super(key: key);

  @override
  State<RandomWords> createState() => _RandomWordsState();
}

class _RandomWordsState extends State<RandomWords> {
  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

 

 

 

 

 

 

 

 

 

 

 

 

https://codelabs.developers.google.com/codelabs/first-flutter-app-pt2#0

 

Write Your First Flutter App, part 2  |  Google Codelabs

Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase. In this codelab, you’ll extend a simple mobile app to add interactivity, navigation, and change its theme color.

codelabs.developers.google.com

 

  • web์—์„œ 

https://docs.flutter.dev/get-started/codelab-web

 

Write your first Flutter app on the web

How to create a Flutter web app.

docs.flutter.dev

 

 

 

๋ฐ˜์‘ํ˜•

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

[Flutter] Erros..  (0) 2023.03.08
[Flutter]  (0) 2022.05.20
์ฃผ์„  (0) 2020.05.18
Dart cheatsheet codelab  (0) 2020.01.02