2022. 1. 11. 17:00ㆍFlutter
사용자의 동작을 감지하는 것을 Gesture라고 한다.
GestureDetector와 InkWell을 통해 Gesture를 감지할 수 없는 위젯(Container, Image 등)에 Gesture 기능을 줄 수 있다.
사용법은 거의 동일하다.
GestureDetector(
onTab: () {
// 클릭 시 실행될 것
},
child: 위젯,
);
InkWell(
onTab: () {
// 클릭 시 실행될 것
},
child: 위젯,
);
다만 차이점이 있다면
1. InkWell은 onTab, onDoubleTap 등 자주 쓰는 제스처정도만 지원하는데 반해 GestureDetector은 드래그 제스처를 포함해 훨씬 많고 상세한 제스처 제어가 가능하다.
2. GestureDetector는 사용자의 동작을 감지할 때 별도의 애니메이션 효과가 없는데 반해 InkWell은 Ripple Animation이라고 하는 잉크가 퍼져나가는 듯한 애니메이션 효과를 제공한다.
참고
https://api.flutter.dev/flutter/widgets/GestureDetector-class.html
GestureDetector class - widgets library - Dart API
A widget that detects gestures. Attempts to recognize gestures that correspond to its non-null callbacks. If this widget has a child, it defers to that child for its sizing behavior. If it does not have a child, it grows to fit the parent instead. By defau
api.flutter.dev
https://api.flutter.dev/flutter/material/InkWell-class.html
InkWell class - material library - Dart API
A rectangular area of a Material that responds to touch. For a variant of this widget that does not clip splashes, see InkResponse. The following diagram shows how an InkWell looks when tapped, when using default values. The InkWell widget must have a Mate
api.flutter.dev
'Flutter' 카테고리의 다른 글
Flutter 앱 빌드가 안될 때 (0) | 2022.01.14 |
---|---|
안드로이드 에뮬레이터에서 한글 키보드 쓰기 (0) | 2022.01.12 |
Stack과 Positioned (0) | 2022.01.11 |
Null safety 이해하기 (0) | 2022.01.10 |
bottom navigation tab 만들기 (0) | 2022.01.10 |