Scalffold
κΈ°λ³Έμ μΈ μ±μ νλ©΄ κ΅¬μ± μμ λ΄λ 컨ν
μ΄λ μμ ―
Scalffold ꡬμ±μμ
β’
AppBar
β’
Body
β’
FloatingActionsButton
β’
Drawer
β’
BottomNavitaionBar
β’
BottomSheet
AppBar (μ± λ°):
β’
AppBarλ νλ©΄ μλ¨μ μμΉνλ©°, μ±μ μ λͺ©μ΄λ λ€μν μ‘μ
λ€μ ν¬ν¨ν μ μλ μλ¨ λ°μ
λλ€.
Body (λ°λ):
β’
Bodyλ μ±μ λ³Έλ¬Έ λ΄μ©μ λ΄λ λΆλΆμ
λλ€. μ£Όλ‘ ν
μ€νΈ, μ΄λ―Έμ§, 리μ€νΈ, νΌ λ±μ UI μμλ€μ΄ λ°°μΉλ©λλ€.
FloatingActionButton (νλ‘ν μ‘μ λ²νΌ):
β’
FloatingActionButtonμ μΌλ°μ μΌλ‘ μ±μμ μμ£Ό μ¬μ©λλ μ£Όμ λμμ μννλ λ²νΌμ
λλ€. μ£Όλ‘ νλ©΄ νλ¨μ μμΉνλ©°, λλ μ λ νΉμ λμμ΄ μ€νλ©λλ€.
Drawer (λλ‘μ΄):
β’
Drawerλ νλ©΄ μ’μΈ‘μμ μ°μΈ‘μΌλ‘ λνλλ μ¬μ΄λ λ©λ΄λ₯Ό μ 곡ν©λλ€. μ£Όλ‘ λ€λΉκ²μ΄μ
λ©λ΄λ μ€μ λ©λ΄ λ±μ λ΄μ΅λλ€.
BottomNavigationBar (νλ¨ λ€λΉκ²μ΄μ λ°):
β’
BottomNavigationBarλ νλ©΄ νλ¨μ μμΉνλ©°, μ¬λ¬ κ°μ νλ©΄μΌλ‘ μ΄λνλ νμ μ 곡ν©λλ€.
BottomSheet (νλ¨ μνΈ):
β’
BottomSheetλ νλ©΄ νλ¨μμ λνλλ λΆκ°μ μΈ μ 보λ₯Ό λ΄λ UI μμμ
λλ€.
Scaffold μμ
main.dart
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
// App Bar
appBar: AppBar(
title: Text('My App'),
),
// Body
body: const Center(
child: Text('Hello Flutter~!'),
),
// floatingActionsButton
floatingActionButton: FloatingActionButton(
onPressed: () {
print('click!');
},
child: const Icon(Icons.person),
),
// drawer (μ¬μ΄λλ°)
drawer: Drawer(
child: ListView(
children: [
const DrawerHeader(
decoration: BoxDecoration(
color: Colors.blue,
),
child: Text("λ©λ΄ λͺ©λ‘"),
),
ListTile(
title: const Text('λ©λ΄ 1'),
onTap: () { print('click menu1!'); },
),
ListTile(
title: const Text('λ©λ΄ 2'),
onTap: () { print('click menu2!'); },
),
],
),
),
// BottomNavitaionBar
bottomNavigationBar: BottomNavigationBar(
// μμ΄ν
2κ° μ΄μ
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.search),
label: 'Search',
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'user',
),
],
),
// BottomSheet
bottomSheet: Container(
height: 20,
color: Colors.grey,
child: const Center(child: Text('Bottom')),
),
);
}
}
Dart
볡μ¬