๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ“ฑ|APP DEV/Flutter

[Flutter] ํ”Œ๋Ÿฌํ„ฐ 1์ฃผ์ฐจ(2) - ๊ตฌ์กฐ, ์‹œ์ž‘ํ•˜๊ธฐ(VSCode)

by KASSID 2023. 1. 23.

๋ชฉ์ฐจ

    728x90

    2023.01.19 - [๐Ÿ“ฑ|APP DEV/Flutter] - [Flutter] ํ”Œ๋Ÿฌํ„ฐ 1์ฃผ์ฐจ(1) - ํŠน์ง•, ํ™˜๊ฒฝ์„ค์ •(Mac)

    ๊ตฌ์กฐ

    Flutter๋Š” ์œ„์ ฏ(Widget)์œผ๋กœ ๋ชจ๋“  ๊ฒƒ์ด ๊ตฌ์„ฑ๋œ๋‹ค.

    ์œ„์ ฏ์€ '์ž‘์€ ๋ชจ๋“ˆ'์ด๊ณ  ์ด๊ฒƒ์„ ๋ถ™์ด๊ณ  ๋ถ™์—ฌ์„œ ํ•˜๋‚˜์˜ ์•ฑ์„ ๋งŒ๋“ ๋‹ค.

     

    https://docs.flutter.dev/development/ui/widgets

    ์œ„์˜ ๋งํฌ์—์„œ๋Š” Flutter ๊ณต์‹๋ฌธ์„œ์—์„œ ์ œ๊ณตํ•˜๋Š” ์œ„์ ฏ๋“ค์„ ์‚ดํŽด๋ณผ ์ˆ˜ ์žˆ๋‹ค.

    ๋ณ„๋„์˜ ํŒจํ‚ค์ง€ ์—†์ด ๊ฐ„ํŽธํ•˜๊ฒŒ ์ฝ”๋“œ๋งŒ ์ž…๋ ฅํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

     

    ์ด๋•Œ Andriod์™€ iOS์˜ ํ™”๋ฉด ๊ตฌ์„ฑ์„ ๊ตฌํ˜„ํ•œ ์œ„์ ฏ์˜ ์ด๋ฆ„์ด ๊ตฌ๋ถ„๋œ๋‹ค.

     Material Widget 
     - Android ๊ธฐ๋ณธ ํ™”๋ฉด ๊ตฌ์„ฑ ์š”์†Œ

     Cupertino Widget 
     - iOS ํ™”๋ฉด ๊ตฌ์„ฑ ์š”์†Œ

     Custom Widget 
     - ์‚ฌ์šฉ์ž ๊ณ ์œ  ๋””์ž์ธ ์š”์†Œ

     


    ์‹œ์ž‘ํ•˜๊ธฐ(VSCode)

    1. command-shift-p ๋‹จ์ถ•ํ‚ค๋กœ ์ปค๋งจ๋“œ ํŒ”๋ ˆํŠธ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.

    2. Flutter: New Project๋ฅผ ํด๋ฆญํ•˜๊ณ  Application์„ ์„ ํƒํ•œ๋‹ค.

    3. ๊ฐœ๋ฐœ์„ ์ง„ํ–‰ํ•  ํด๋”๋ฅผ ์„ ํƒํ•œ๋‹ค.

    4. ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ด๋ฆ„์„ ์„ค์ •ํ•œ๋‹ค.

    5. ํ”„๋กœ์ ํŠธ๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค.

    ์™„์„ฑ๋œ ๋ชจ์Šต

     lib ํด๋” : ๋ฉ”์ธ ์ž‘์—… ํด๋”
     pupspec.yaml : ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์ • ํŒŒ์ผ
     main.dart : ์ฒซ์‹œ์ž‘ ํ™”๋ฉด
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            appBar: AppBar(),
          ),
        );
      }
    }

     

    + Tip_์ฝ”๋“œ ํŒŒ๋ž€์‹ค์„  ์ œ๊ฑฐํ•˜๊ธฐ & dart recommend(VSCode)

    1. ์ฝ”๋“œ ํŒŒ๋ž€์‹ค์„  ์ œ๊ฑฐ

    analysis_options.yaml ํŒŒ์ผ ์ˆ˜์ •

    prefer_const_constructors: false
    prefer_const_literals_to_create_immutables: false

     

    2. dart recommend(VSCode)

    command+shift+P (command palette) ์‹คํ–‰ ํ›„

    dart recommend๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

    ์ž๋™ ์ •๋ ฌ๊ธฐ๋Šฅ ๋“ฑ์˜ dart ๊ฐœ๋ฐœ์— ์œ ์šฉํ•œ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค.

     

    ์—๋ฎฌ๋ ˆ์ดํ„ฐ ๊ตฌ๋™ํ•˜๊ธฐ

    command+shift+P (command palette) ์‹คํ–‰ ํ›„

    launch๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

    ์ด์ „์— ์ƒ์„ฑํ•œ ์—๋ฎฌ๋ ˆ์ดํ„ฐ๊ฐ€ ๋ชฉ๋ก์— ๋ณด์ธ๋‹ค.

     

    ์‹คํ–‰ํ•˜๊ธฐ

    Run without Debugging ๋“ฑ์œผ๋กœ ์‹คํ–‰ํ•œ๋‹ค.

     


     

    ๋Œ“๊ธ€