์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- dart
- stateful
- ontap
- PushNamed
- textField
- scaffoldmessenger
- Routing
- drawer
- flutter
- button
- ElevatedButton
- AppBar
- switch
- POP
- InputDecoration
- Snackbar
- image
- icon
- vscode
- slider
- AlertDialog
- navigator
- GestureDetector
- figma
- sizedbox
- TextEditingController
- Scaffold
- list
- FloatingActionButton
- Webflow
- Today
- Total
์ฌ๋ฐ๋๊ฑฐ๐
Flutter_12. Package, Gesture, List, Image, Swipe, Button ๋ณธ๋ฌธ
Flutter_12. Package, Gesture, List, Image, Swipe, Button
uraon 2023. 5. 6. 00:17์ง๋ ๋ฒ ๋ณ๋ ํ์ผ๋ก body๋ฅผ ๋ถ๋ฆฌํ์๋ค. ์ด์ด์ ํํ๋ฉด์ ๋ง๋ค์ด ๋ณด๊ฒ ๋ค.
ํ์ผ์ img_swipe.dart ์ ์ด์ด์ ์์ ํ ์์ ์ด๋ค.
2023.05.05 - [๊ฐ๋ฐํ๊ธฐ] - Flutter_11. Drawer, ListTitle, Navigator, body, class, Stateful
Flutter_11. Drawer, ListTitle, Navigator, body, class, Stateful
์ค๋์ ์ง๋๋ฒ ํฌ์คํ ์ ์ด์ด์ Drawer์ ๋ฆฌ์คํธ๋ฅผ ๋ง๋ค๊ณ ํ์ด์ง ์ด๋์ ์์ผ๋ณด๋๋ก ํ๊ฒ ๋ค. 2023.05.04 - [๊ฐ๋ฐํ๊ธฐ] - Flutter_10. Drawer, AppBar IconButton Flutter_10. Drawer, AppBar IconButton ์ค๋์ AppBar์ IconBut
uraon.tistory.com
Packages, Gesture
1) pub.dev ์์ gesture ๊ฒ์
https://pub.dev/packages/simple_gesture_detector
simple_gesture_detector | Flutter Package
Easy to use, reliable and lightweight gesture detector for Flutter apps. Exposes simple API to react to basic gestures.
pub.dev
2) ๋ณต์ฌ
3) pubspec.yaml ํ์ผ์ ๋ฃ๊ณ ์ ์ฅ
Image, List, SimpleGestureDetector, Swipe
1) ๋ฆฌ์คํธ ๋ง๋ค๊ธฐ
2) body์ ์ฌ์ฉํ๊ณ ์ถ๋ ฅ ํ์ธ
3) SimpleGestureDetector๋ก Wrap
- Center ํด๋ฆญํ๊ณ ์ ๊ตฌ(๐ก) ํด๋ฆญ
- Wrap with Widget ์ ํํ๊ณ , "SimpleGestureDetector"๋ก ์ด๋ฆ ๋ณ๊ฒฝ
- SimpleGestureDetector์ ๋นจ๊ฐ ์ค ๋จ๋ฉด, ์ ๊ตฌ(๐ก) ํด๋ฆญํ์ฌ Import Library
4) onHorizontalSwipe:, onVerticalSwipe: ์ ํจ์ ์ฌ์ฉ
5) ์ข์ฐ ์ค์์ดํ ํจ์ ๋ง๋ค๊ธฐ : _onHorizontalSwipe(SwipeDirection direction)
// --- ์ข์ฐ ์ค์์ดํ Func
_onHorizontalSwipe(SwipeDirection direction){
if(direction == SwipeDirection.left){
setState(() {
currentImage+=1;
if(currentImage >= imageName.length){
currentImage = 0;
}
});
}else{
setState(() {
currentImage-=1;
if(currentImage < 0){
currentImage = imageName.length - 1;
}
});
}
}
6) ์์๋ ์ค์์ดํ ํจ์ ๋ง๋ค๊ธฐ : _onVerticalSwipe(SwipeDirection direction)
// --- ์์๋ ์ค์์ดํ Func
_onVerticalSwipe(SwipeDirection direction){
if(direction == SwipeDirection.up){
setState(() {
currentImage+=1;
if(currentImage >= imageName.length){
currentImage = 0;
}
});
}else{
setState(() {
currentImage-=1;
if(currentImage < 0){
currentImage = imageName.length - 1;
}
});
}
}
7) ์ ์ฅํ๊ณ ํ๋ฉด ํ์ธํด๋ณด๋, ์ข ์ด์ํด์ padding๊ณผ SizedBox๋ก ์ด๋ฏธ์ง ๋ด๊ธฐ ์ถ๊ฐ ์งํ!
8) ์ ์ฅํ๊ณ ํ๋ฉด ํ์ธ ๋ฐ ์ด๋ฏธ์ง ์ค์์ดํ ํ ์คํธ
Image, List, SimpleGestureDetector, Button
1) ๋ฒํผ์ setState๋ก ์ด๋ฒคํธ : ๋ฒํผ [์ด์ ์ผ๋ก] ํด๋ฆญ ์ ํ์ฌ ์ด๋ฏธ์ง์์ -1
2) ๋ฒํผ์ setState๋ก ์ด๋ฒคํธ : ๋ฒํผ [๋ค์์ผ๋ก] ํด๋ฆญ ์ ํ์ฌ ์ด๋ฏธ์ง์์ +1
3) ์ ์ฅํ๊ณ ํ๋ฉด ํ์ธ ๋ฐ ๋ฒํผ ํด๋ฆญ ์ ์ด๋ฏธ์ง ๋ณ๊ฒฝ ํ์ธ
'๊ฐ๋ฐํ๊ธฐ > Flutter Start' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Flutter_14. Model, Class, List, Card, floatingActionButton (0) | 2023.05.08 |
---|---|
Flutter_13. Stateful, Switch, setState, Button (0) | 2023.05.06 |
Flutter_11. Drawer, ListTitle, Navigator, body, class, Stateful (0) | 2023.05.05 |
Flutter_10. Drawer, ListView, UserAccountsDrawerHeader, AppBar IconButton (0) | 2023.05.04 |
Flutter_09.Navigator, Push, PushNamed, Pop (0) | 2023.05.03 |