์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 | 31 |
- GestureDetector
- ElevatedButton
- vscode
- slider
- sizedbox
- Snackbar
- flutter
- icon
- POP
- Webflow
- image
- scaffoldmessenger
- TextEditingController
- Routing
- dart
- ontap
- drawer
- stateful
- navigator
- button
- switch
- list
- FloatingActionButton
- textField
- PushNamed
- figma
- InputDecoration
- AppBar
- AlertDialog
- Scaffold
- Today
- Total
์ฌ๋ฐ๋๊ฑฐ๐
Flutter_08. AlertDialog, Navigator, Routing, PushNamed ๋ณธ๋ฌธ
Flutter_08. AlertDialog, Navigator, Routing, PushNamed
uraon 2023. 5. 3. 19:30Flutter๋ ํ๋ฉด ๊ฐ ํ์ ๋ฐ ๋ฅ ๋งํฌ ์ฒ๋ฆฌ๋ฅผ ์ํ ์์ ํ ์์คํ ์ ์ ๊ณตํ๋ค๊ณ ํ๋ค.
๋ด๋น๊ฒ์ด์ ๊ณผ ๋ผ์ฐํฐ๋ฅผ ์ด์ฉํ ํ๋ฉด ์ด๋์ ๋ณต์ตํด๋ณด๊ฒ ๋ค :) ์์ธํ ๋ด์ฉ ๋ฐ ์ถ๊ฐ์ ์ธ ๋ ์ํผ๋ ์๋ ๋งํฌ์์ ํ์ธ!
https://docs.flutter.dev/ui/navigation
Navigation and routing
Overview of Flutter's navigation and routing features
docs.flutter.dev
https://docs.flutter.dev/cookbook#navigation
Cookbook
The Flutter cookbook provides recipes for many commonly performed tasks.
docs.flutter.dev
GestureDetector, onTap, AlertDialog
1) lib์ ํด๋ ๋ง๋ค๊ณ , dart ํ์ผ ์ ๊ท ์์ฑ - ๊ธฐ๋ณธ ํ๋ฉด ์ ํ
2) body์ GestureDetector ์ถ๊ฐ
GestureDetector
- onTap: () => ํธ์ถํ ํจ์
- child: cont Text('์ถ๋ ฅํ ๋ฌธ๊ตฌ')
3) AlertDialog ํจ์ ์์ฑํ๊ณ showDialog();
_showAlertDialog(BuilderContext context){}
- showDialog(context: context, builder: builder);
4) builder์ return AlertDialog();
showDialog();
- context: context
- builder: (BuildContext ctx){
return AlertDialog();
}
5) AlertDialog ๊ธฐ๋ณธ ๋ ์ด์์ ์ ํ
AlertDialog();
- ์นผ๋ผ backgroundColor: const Colors.์ํ๋์นผ๋ผ
- ์ ๋ชฉ title: const Text('๋ค์ด์ด๋ก๊ทธ ์ ๋ชฉ ๋ฌธ๊ตฌ')
- ๋ด์ฉ content: const Text('๋ค์ด์ด๋ก๊ทธ ๋ด์ฉ ๋ฌธ๊ตฌ')
- ๋ฒํผ actions: [๋ฒํผ, ๋ฒํผ, ...]
6) AlertDialog ๋ฒํผ ์ ํ
actions: []
- Center > Row > TextButton
7) ์ ์ฅํ๊ณ AlertDialog ์ถ๋ ฅ ํ์ธ
๋ฒํผ ํด๋ฆญ ์ ์๋ฌด๋ฐ ์ด๋ฒคํธ๊ฐ ์๊ธฐ ๋๋ฌธ์, [์][์๋์] ๋ฒํผ์ ํด๋ฆญํด๋ AlertDialog๊ฐ ๋ซํ์ง ์์
8) ๋ฒํผ์ Navigator pop() ์ถ๊ฐ
9) ์ ์ฅํ๊ณ AlertDialog ์ถ๋ ฅ ๋ฐ ๋ซํ ํ์ธ
10) showDialog์ barrierDismissible์ barrierColor ์ค์
showDialog();
- barrierDismissible: true //Alert ์ธ ์์ญ ํฐ์น์ ๋ซ๊ธฐ ํ์ฉ
- barrierColor //Alert ์ถ๋ ฅ์ BG์นผ๋ผ
- context: context
- builder: (BuildContext ctx){
return AlertDialog();
}
11) Command + S ๋๋ โก๏ธ ์์ด์ฝ ๋ฒํผ ํด๋ฆญํ์ฌ ํ๋ฉด ํ์ธ
Page, Routing, Navigator, PushNamed
1) main.dart ํ์ผ์ Routing ์ ํ
2) ๋ณ๋ page ํ์ผ 2๊ฐ ์์ฑํ๊ณ ๊ธฐ๋ณธ ์ ํ
//appBar ํ์ดํ๊ณผ body์ ํ ์คํธ ๋ฌธ๊ตฌ๋ง ๋ค๋ฅด๊ณ ๋์ผ ์ฝ๋
3) main.dart ํ์ผ์ ์์ฑํ 2๊ฐ ํ์ด์ง Routing ์ ํ
4) home.dart ํ์ผ์ AlertDialog ๋ฒํผ ํด๋ฆญ์ ์ด๋ฒคํธ๋ก ํ์ด์ง ์ด๋ pushNamed ์ค์
Navigator.of(ctx).pop();
Navigator.pushNamed(context, '/1st');
5) ์ ์ฅํ๊ณ , ํ์ด์ง ์ด๋ ํ์ธ
'๊ฐ๋ฐํ๊ธฐ > Flutter Start' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Flutter_10. Drawer, ListView, UserAccountsDrawerHeader, AppBar IconButton (0) | 2023.05.04 |
---|---|
Flutter_09.Navigator, Push, PushNamed, Pop (0) | 2023.05.03 |
Flutter_07. ScaffoldMessenger, SnackBar, Function (0) | 2023.05.02 |
Flutter_06. GestureDetector, onTap, AlertDialog (0) | 2023.05.02 |
Flutter_05. Button, Link, launchUrl, Plugins (0) | 2023.04.29 |