개발/Flutter
Buildcontext
Byunpa24
2021. 6. 27. 15:59
반응형
'A handle to the location of a widget in the widget tree'
Widget tree에서 현재 widget의 위치를 알 수 있는 정보
build method의 Type은 Widget
거기 안에 들어가는 인자값 context 의 type은 BuildContext
build 함수는 scaffold 라는 widget 을 return 하고 이때에 widget tree 상에서 어디에 위치하는지에 대한 정보를 가지고 있는 context라는 정보를 넣어서 return 한다.
'Each widget has its own BuildContext, which becomes the parent of the widget returned by the statelesswidget.build or state.build function
이 BuildContext는 stateless 위젯이나 state 빌드 메서드에 의해서 리턴 된 위젯의 부모가 된다.
context는 buildcontext class의 instance
*Something.of(context) method" ==> 현재 주어진 context에서 위로 올라가면서 가장 가까운 Something을 찾아서 반환하라
반응형