์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
- rxcocoa
- Flutter
- raywenderlich
- visionOS
- swift
- designpattern
- BFS
- SnapKit
- arkit
- ํ๋ก๊ทธ๋๋จธ์ค
- TCA
- Xcode
- Swfit
- tableView
- reactorkit
- XCTest
- ios
- SwiftUI
- Kuring
- MVVM
- BOJ
- combine
- CollectionView
- node.js
- UIKit
- Lv2
- RxSwift
- realm
- ํจ์คํธ์บ ํผ์ค
- ๋ฐฑ์ค
- Today
- Total
lgvv98
[flutter] 14๊ฐ | Appbar ๋ฉ๋ด ์์ด์ฝ ์ถ๊ฐํ๊ธฐ ๋ณธ๋ฌธ
[flutter] 14๊ฐ | Appbar ๋ฉ๋ด ์์ด์ฝ ์ถ๊ฐํ๊ธฐ
๐ฅ ์บ๋ฟ๋งจ 2021. 8. 10. 16:09โ ์ด๋ฒ ์๊ฐ์๋ Appbar ๋ฉ๋ด ์์ด์ฝ ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ์ ๋ํด์ ์์๋ณด์.
์ค์ํํธ์์๋ ๋ค๋น๊ฒ์ด์ ๋ฐ๋ผ๊ณ ๋ถ๋ฅธ๋ค..!
์์ํ๊ธฐ์ ์์...
์ด๋ฒ์๋ print๋ฅผ ํตํด ๋ก๊ทธ๋ฅผ ์ฐ์ด๋ณด๋ ์์ ์ด ๋ง์๋๋ฐ ์๋๋ก์ด๋ ์คํ๋์ค์์๋ ๋ก๊ทธ๋ฅผ ๋ณผ ์ ์๋ ์ฐฝ์ด ์๋ณด์ด๋๊ฑฐ์...
์ง์ง ๋๋ฌด ๋ถ๋ ธํ ์ํ์์ ์ด๋ป๊ฒ ํ ๊น.. ์ฐพ์๋ณด๋ค๊ฐ ๋ฐ๋ก...!
๋ณด์ด๋๊ฐ?
์คํ ์์ ๋ฒ๋ ๋ชจ์์ ํด๋ฆญํ๋ฉด console์ฐฝ์ด ์ด๋ฆฌ๋ฉด์ ๋๋ฒ๊น ์ฝ์์ด ์ด๋ ค ใ ...
์ด๊ฑฐ ์์ผ๋ฉด json ๋ด๋ ค๋ฐ์์ ๊ตฌ์กฐ๋ณผ ๋ ์ด๋ป๊ฒ ํ๋์ง ๊ณ ๋ฏผ์ด์๋๋ฐ ์๋ฌดํผ
โ ์ฝ๋๋ฆฌ๋ทฐ ๋ฐ ์ฝ๋ ์ดํด
import 'package:flutter/material.dart'; // ๋ฐ์คํฌํ, ์ฑ ๋ฑ์ ๊ณ ๋ฃจ UI๋ฅผ ์ ์ฉํ ์ ์๊ฒ ํด์ฃผ๋ ๊ตฌ๊ธ์ด ์ ๊ณตํด์ฃผ๋ ํจํค
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
// ์ค์ง์ ์ผ๋ก ๋ชจ๋ ์ฑ์ ๊ฐ์ธ๊ณ ์๋ค.
title: 'Appbar', // ์ฑ์ ์ด์นญํ๋ ์ด๋ฆ -> ์ค๋งํธ ํฐ ์ฑ์์ ์ต๊ทผ ์ฌ์ฉํ ์ฑ ๋ณด์ฌ์ค ๋์ ์ด๋ฆ
theme: ThemeData(primarySwatch: Colors.red // ํน์ ์์ ์์ฉ๋ค์ ๊ธฐ๋ณธ ์์์ผ๋ก ์ง์ ํด์ ์ฌ์ฉํ๊ฒ
),
home: MyPage(), // home์ ์ฑ์ด ์คํ๋ ๋ ๊ฐ์ฅ๋จผ์ ๋ณด์ฌ์ฃผ๋ ํ์ด
);
}
}
class MyPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('AppBar icon menu'),
elevation: 0.0,
leading: IconButton(
// ๊ฐ๋จํ ์์ ฏ์ด๋ ํ์ดํ๋ค์ ์ฑ๋ฐ์ ์ผ์ชฝ์ ์์น์ํค๋ ๊ฒ์ ๋งํจ
icon: Icon(Icons.menu), // ์์ด์ฝ
onPressed: () {
// ๋ฒํผ์ ๋๋ ์ ๋
print("menu button is clicked");
},
),
actions: [ // action ์์ฑ์ ๋ณต์์ ์์ด์ฝ ๋ฒํผ ๋ฑ์ ์ค๋ฅธ์ชฝ์ ๋ฐฐ์นํ ๋
IconButton(
// ๊ฐ๋จํ ์์ ฏ์ด๋ ํ์ดํ๋ค์ ์ฑ๋ฐ์ ์ผ์ชฝ์ ์์น์ํค๋ ๊ฒ์ ๋งํจ
icon: Icon(Icons.shopping_cart), // ์์ด์ฝ
onPressed: () {
// ๋ฒํผ์ ๋๋ ์ ๋
print("shopping_cart is clicked");
},
),
IconButton(
// ๊ฐ๋จํ ์์ ฏ์ด๋ ํ์ดํ๋ค์ ์ฑ๋ฐ์ ์ผ์ชฝ์ ์์น์ํค๋ ๊ฒ์ ๋งํจ
icon: Icon(Icons.search), // ์์ด์ฝ
onPressed: () {
// ๋ฒํผ์ ๋๋ ์ ๋
print("search is clicked");
},
)
],
),
);
}
}
leading๊ณผ action ๊ทธ๋ฆฌ๊ณ IconButton ์ ๋๊ฐ ์ ์๊น๊ฒ ๋ณผ ์ฌํญ์ด์์ด.
'flutter > ์ํ๋ง(๊ธฐ์ด)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[flutter] 16๊ฐ | Drawer ๋ฉ๋ด ๋ง๋ค๊ธฐ 2 (0) | 2021.08.11 |
---|---|
[flutter] 15๊ฐ | Drawer ๋ฉ๋ด ๋ง๋ค๊ธฐ 1 (0) | 2021.08.10 |
[flutter] 12๊ฐ~13๊ฐ | Dart ํต์ฌ์ ๋ฆฌ : ํด๋์ค์ ์์ ฏ์ ์ ์ฒด (0) | 2021.08.10 |
[flutter] 10๊ฐ~11๊ฐ | ์บ๋ฆญํฐ ํ์ด์ง ๋์์ธ 2,3: ์ค์ ์ฝ๋ฉ ์๊ฒฐ (0) | 2021.08.10 |
[flutter] 9๊ฐ | ์บ๋ฆญํฐ ํ์ด์ง ๋์์ธ 1 : ์์ ฏ์ ๋ฆฌ (0) | 2021.08.10 |