含义:
A handle to the location of a widget in the widget tree.
BuildContext是Widget在Widget树中位置的句柄。
原因:
BuildContext objects are actually Element objects. The BuildContext interface is used to discourage direct manipulation of Element objects.
BuildContext对象其实是一个element,BuildContext接口被用来阻止直接操作element对象;
特点:
Each widget has its own BuildContext, which becomes the parent of the widget returned by the StatelessWidget.build or State.build function. (And similarly, the parent of any children for RenderObjectWidgets.)
每个widget都有一个BuildContext,BuildContext会成为StatelessWidget.build or State.build function返回widget的父亲。
应用
在flow布局中BuildContext代表flow控件的位置,可以用来绘制子控件;
网友评论