HIDI Flutter Challenge (1) Flutter Structure

hello_hidiยท2021๋…„ 8์›” 28์ผ
0

HIDI's Flutter Challenge

๋ชฉ๋ก ๋ณด๊ธฐ
1/12
post-thumbnail

> Flutter Structure

> MaterialApp vs CupertinoApp

MaterialApp : Android ๋””์ž์ธ
CupertinoApp : iOS ๋””์ž์ธ

> Scaffold

๊ฐ€์žฅ ์ตœ ์ƒ๋‹จ, ์ค‘๊ฐ„ ์˜์—ญ, ์ตœํ•˜๋‹จ, ๊ทธ๋ฆฌ๊ณ  ๋–  ์žˆ๋Š” ๋ฒ„ํŠผ์„ ์ง€์›ํ•ด์ฃผ๋Š” ํด๋ž˜์Šค
a.k.a ๊ตฌ์กฐ๊ฐ€ ์žˆ๋Š” ๋„ํ™”์ง€

  
  const Scaffold(
    {Key? key,
    PreferredSizeWidget? appBar,
    Widget? body,
    Widget? floatingActionButton,
    FloatingActionButtonLocation? floatingActionButtonLocation,
    FloatingActionButtonAnimator? floatingActionButtonAnimator,
    List? persistentFooterButtons,
    Widget? drawer,
    DrawerCallback? onDrawerChanged,
    Widget? endDrawer,
    DrawerCallback? onEndDrawerChanged,
    Widget? bottomNavigationBar,
    Widget? bottomSheet,
    Color? backgroundColor,
    bool? resizeToAvoidBottomInset,
    bool primary,
    DragStartBehavior drawerDragStartBehavior,
    bool extendBody,
    bool extendBodyBehindAppBar,
    Color? drawerScrimColor,
    double? drawerEdgeDragWidth,
    bool drawerEnableOpenDragGesture,
    bool endDrawerEnableOpenDragGesture,
    String? restorationId}
  )

1) AppBar
- ํ•ด๋‹น ํ™”๋ฉด์— ๋Œ€ํ•œ ๋ฉ”๋‰ด๋‚˜ ์ด๋™ ๋ฒ„ํŠผ, ๊ทธ๋ฆฌ๊ณ  ์ œ๋ชฉ ๊ฐ™์€ ๊ฒƒ๋“ค์„ ๊ฐ€์ง€๊ณ  ์žˆ์Œ
- Android์—์„œ TitleBar, iOS์—์„œ๋Š” NavigationBar๋กœ ๋ถˆ๋ฆฌ๋Š” ์˜์—ญ

2) Body
- ๊ฐ€์šด๋ฐ ์˜์—ญ์„ ๋‹ด๋‹น

3) BottomNavigationBar
- ๋‹ค๋ฅธ ์ฐฝ์œผ๋กœ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฒ„ํŠผ๋“ค์ด ์žˆ๋Š” ์˜์—ญ
- Android์—์„  Bottom Navigation Bar๋ผ๋Š” ๋ช…์นญ์„ ๊ทธ๋Œ€๋กœ ์“ฐ๊ณ  ์žˆ๊ณ  iOS์—์„  Tab Bar๋กœ ๋ถˆ๋ฆฌ๋˜ ์˜์—ญ

4) FloatingActionButton
- ์ฐฝ ์œ„์— ๋– ์žˆ๋Š” ํšจ๊ณผ๋ฅผ ์ฃผ๋Š” ๋ฒ„ํŠผ
- Android์—์„  support library๋ฅผ ํ†ตํ•ด์„œ FloatingActionButton์„ ์ง€์›
- iOS ์—์„  ์ง์ ‘ ๋ฒ„ํŠผ์„ ๋ฐฐ์น˜ํ•ด์„œ ์‚ฌ์šฉ

์˜ˆ์‹œ์ฝ”๋“œ


import 'package:flutter/material.dart';

void main() => runApp(MyApp());

/// This is the main application widget.
class MyApp extends StatelessWidget {
  static String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: MyStatefulWidget(),
    );
  }
}

/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
  @override
  State createState() => _MyStatefulWidgetState();
}

/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State {
  int _count = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Sample Code'),
      ),
      body: Center(child: Text('You have pressed the button $_count times.')),
      floatingActionButton: FloatingActionButton(
        onPressed: () => setState(() => _count++),
        tooltip: 'Increment Counter',
        child: const Icon(Icons.add),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(
            label: "forward",
            icon: Icon(Icons.forward),
          ),
          BottomNavigationBarItem(
            label: "home",
            icon: Icon(Icons.home),
          ),
          BottomNavigationBarItem(
            label: "back",
            icon: Icon(Icons.backspace),
          ),
        ],
      ),
    );
  }
}

}

์‹คํ–‰๊ฒฐ๊ณผ

profile
์•ˆ๋‡ฝํฌ๋””

0๊ฐœ์˜ ๋Œ“๊ธ€