프로그래밍/Flutter & Dart

[Flutter] Inherited Widget

*%$@$#@ 2023. 2. 1. 09:15
728x90
반응형

. 위젯은 of 메서드를 이용해 트리의 상위에 위치한 InheritedWidget의 참조를 얻는다. 

. of 메서드는 트리를 탐색하여 가장 가까운 InheritedWidget 형식을 가진 부모를 찾아 반환한다. 

. 대부분 InheritedWidget 자체에 of 메서드를 정의함

. 파라메터로 전달된 BuildContext로 BuildContext.inheritedFromWidgetOfExactType 메서드를 호출

. inheritedFromWidgetOfExactType은 실제 트리를 검색하는 메서드 -> BuildContext로 부모 위젯에 접근

.inheritedFromWidgetOfExactType은 정적(Static)메서드 -> 어디에서나 호출 가능

 

 

728x90
반응형