MaterialApp : Android ๋์์ธ
CupertinoApp : iOS ๋์์ธ
๊ฐ์ฅ ์ต ์๋จ, ์ค๊ฐ ์์ญ, ์ตํ๋จ, ๊ทธ๋ฆฌ๊ณ ๋ ์๋ ๋ฒํผ์ ์ง์ํด์ฃผ๋ ํด๋์ค
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),
),
],
),
);
}
}
}