Toy Project/iGPT

[iGPT] Version 1.0.1

mindw96 2023. 5. 4. 09:43

구현 내용

1. 키보드가 아닌 부분 터치시 키보드 내려가게 구현

 

구현 방법

 채팅과 입력 TextField가 있는 부분인 Column을 GestureDetector로 감싸서 구현

GestureDetector : 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

FocusScope : https://api.flutter.dev/flutter/widgets/FocusScope-class.html

 

FocusScope class - widgets library - Dart API

A FocusScope is similar to a Focus, but also serves as a scope for its descendants, restricting focus traversal to the scoped controls. For example a new FocusScope is created automatically when a route is pushed, keeping the focus traversal from moving to

api.flutter.dev

 

정확한 원리는 Context에 대해서 더 공부해야겠다.

지금 이해한 작동 원리는 Scaffold Widget이 가지고 있는 Context(키보드 외의 모든 부분)을 ontap하면 키보드가 활성화되게 된 TextField의 focus가 unfocus 되기 때문이라고 이해했다.