티스토리 뷰

개발/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을 찾아서 반환하라 

 

 

 

반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG more
«   2025/02   »
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
글 보관함