BuildContext翻译

///小部件树中小部件位置的句柄。
///
///这个类提供了一组可以从StatelessWidget中使用的方法。[State]对象上的方法。
///
/// [BuildContext]对象被传递给[WidgetBuilder]函数(例如[StatelessWidget.build]),并且可以从[State. build]中获得。上下文)成员。
///一些静态函数(例如:[showDialog], [Theme.]的,等等)也获取构建上下文,以便它们可以代表调用小部件,或者获取特定于给定上下文的数据。
///
///每个小部件都有自己的[BuildContext],它成为[StatelessWidget. widget返回的小部件的父部件。建立]或[状态]。构建函数。
///(类似地,[RenderObjectWidget]的任何子元素的父元素。)
///
///特别地,这意味着在一个构建方法中,构建方法的小部件的构建上下文与该构建方法返回的小部件的构建上下文不相同。这可能会导致一些棘手的情况。
///例如,[Theme.of(context)]查找给定构建上下文的最近的封闭[Theme]。如果小部件Q的构建方法在其返回的小部件树中包含[Theme],并尝试使用[Theme]。]传递自己的上下文,Q的构建方法将找不到[Theme]对象。相反,它会找到任何[Theme]是小部件q的祖先。如果需要返回树的子部分的构建上下文,可以使用[Builder]小部件:传递给[Builder.]的构建上下文。builder]回调函数将是[builder]本身的回调函数。
///
///例如,在下面的代码片段中,[ScaffoldState. html]在构建方法本身创建的[Scaffold]小部件上调用showBottomSheet方法。如果没有使用[Builder],而是使用了构建方法本身的' context '参数,则不会找到[Scaffold],并且[脚手架。函数返回null。

@override
Widget build(BuildContext context) {
  // here, Scaffold.of(context) returns null
  return Scaffold(
    appBar: const AppBar(title: Text('Demo')),
    body: Builder(
      builder: (BuildContext context) {
        return TextButton(
          child: const Text('BUTTON'),
          onPressed: () {
            Scaffold.of(context).showBottomSheet<void>(
              (BuildContext context) {
                return Container(
                  alignment: Alignment.center,
                  height: 200,
                  color: Colors.amber,
                  child: Center(
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: <Widget>[
                        const Text('BottomSheet'),
                        ElevatedButton(
                          child: const Text('Close BottomSheet'),
                          onPressed: () {
                            Navigator.pop(context),
                          },
                        )
                      ],
                    ),
                  ),
                );
              },
            );
          },
        );
      },
    )
  );
}

///
///当小部件在树中移动时,特定小部件的[BuildContext]可以随时间改变位置。因此,从该类的方法返回的值不应该在单个同步函数执行之后被缓存。
///
/// {@youtube 560 315 https://www.youtube.com/watch?v=rIaaH87z1-g}
///
/// [BuildContext]对象实际上是[Element]对象。[BuildContext]接口用于阻止对[Element]对象的直接操作。

abstract class BuildContext {
  /// [Element]的当前配置,即[BuildContext]。
  Widget get widget;

  /// 这个上下文的[BuildOwner]。[BuildOwner]负责管理这个上下文的渲染管道。
  BuildOwner? get owner;

  /// [widget]当前是否正在更新小部件或呈现树。
  ///
  /// 对于[StatelessWidget]和[StatelessWidget],当它们各自的构建方法正在执行时,此标志为真。
  /// [RenderObjectWidget]在创建或配置相关的[RenderObject]时将此设置为true。
  /// 其他[Widget]类型可以将此设置为true,用于它们生命周期中概念相似的阶段。
  ///
  /// 当这为真时,[widget]通过调用[dependOnInheritedElement]或[dependOnInheritedWidgetOfExactType]建立对[InheritedWidget]的依赖是安全的。
  ///
  /// 在释放模式下访问该标志无效。
  bool get debugDoingBuild;

  /// The current [RenderObject] for the widget. If the widget is a
  /// [RenderObjectWidget], this is the render object that the widget created
  /// for itself. Otherwise, it is the render object of the first descendant
  /// [RenderObjectWidget].
  ///
  /// This method will only return a valid result after the build phase is
  /// complete. It is therefore not valid to call this from a build method.
  /// It should only be called from interaction event handlers (e.g.
  /// gesture callbacks) or layout or paint callbacks. It is also not valid to
  /// call if [State.mounted] returns false.
  ///
  /// If the render object is a [RenderBox], which is the common case, then the
  /// size of the render object can be obtained from the [size] getter. This is
  /// only valid after the layout phase, and should therefore only be examined
  /// from paint callbacks or interaction event handlers (e.g. gesture
  /// callbacks).
  ///
  /// For details on the different phases of a frame, see the discussion at
  /// [WidgetsBinding.drawFrame].
  ///
  /// Calling this method is theoretically relatively expensive (O(N) in the
  /// depth of the tree), but in practice is usually cheap because the tree
  /// usually has many render objects and therefore the distance to the nearest
  /// render object is usually short.

  ///小部件的当前[RenderObject]。如果小部件是[RenderObjectWidget],这是小部件为自己创建的渲染对象。否则,它是第一个后代[RenderObjectWidget]的渲染对象。
  ///
  ///该方法只在构建阶段完成后才返回有效结果。因此,从构建方法中调用它是无效的。
  ///它只能从交互事件处理程序(例如手势回调)或布局或油漆回调调用。调用if [State]也是无效的。Mounted]返回false。
  ///
  ///如果渲染对象是[RenderBox],这是常见的情况,那么渲染对象的大小可以从[size] getter中获得。这只在布局阶段之后有效,因此应该只从油漆回调或交互事件处理程序(例如,手势回调)中检查。
  ///
  ///关于帧的不同阶段的详细信息,请参见[WidgetsBinding.drawFrame]中的讨论。
  ///
  ///调用这个方法理论上是比较昂贵的(在树的深度中是O(N)),但实际上通常是便宜的,因为树通常有很多渲染对象,因此到最近的渲染对象的距离通常很短。
  RenderObject? findRenderObject();

  /// The size of the [RenderBox] returned by [findRenderObject].
  ///
  /// This getter will only return a valid result after the layout phase is
  /// complete. It is therefore not valid to call this from a build method.
  /// It should only be called from paint callbacks or interaction event
  /// handlers (e.g. gesture callbacks).
  ///
  /// For details on the different phases of a frame, see the discussion at
  /// [WidgetsBinding.drawFrame].
  ///
  /// This getter will only return a valid result if [findRenderObject] actually
  /// returns a [RenderBox]. If [findRenderObject] returns a render object that
  /// is not a subtype of [RenderBox] (e.g., [RenderView]), this getter will
  /// throw an exception in debug mode and will return null in release mode.
  ///
  /// Calling this getter is theoretically relatively expensive (O(N) in the
  /// depth of the tree), but in practice is usually cheap because the tree
  /// usually has many render objects and therefore the distance to the nearest
  /// render object is usually short.

  /// [findRenderObject]返回的[RenderBox]的大小。
  ///
  ///该getter只在布局阶段完成后才返回有效结果。因此,从构建方法中调用它是无效的。
  ///它只能从油漆回调或交互事件处理程序(例如,手势回调)调用。
  ///
  ///关于帧的不同阶段的详细信息,请参见[WidgetsBinding.drawFrame]中的讨论。
  ///
  ///只有当[findRenderObject]返回一个[RenderBox]时,getter才会返回一个有效的结果。如果[findRenderObject]返回的渲染对象不是[RenderBox]的子类型(例如,[RenderView]),此getter将在调试模式抛出异常,并在发布模式返回null。
  ///
  ///调用这个getter在理论上是相对昂贵的(在树的深度中是O(N)),但在实践中通常是便宜的,因为树通常有许多渲染对象,因此到最近的渲染对象的距离通常很短。  
  Size? get size;

  ///将这个构建上下文注册到[祖宗],这样当[祖宗]的小部件改变时,这个构建上下文就会被重新构建。
  /// Registers this build context with [ancestor] such that when [ancestor]'s widget changes this build context is rebuilt.
  ///
  ///返回'祖宗.widget '。
  /// Returns `ancestor.widget`.
  ///
  ///这个方法很少被直接调用。大多数应用程序应该使用[dependOnInheritedWidgetOfExactType],它在找到适当的[InheritedElement]祖先后调用此方法。 
  /// This method is rarely called directly.  Most applications should use [dependOnInheritedWidgetOfExactType], which calls this method after finding the appropriate [InheritedElement] ancestor.
  ///
  ///当[dependOnInheritedWidgetOfExactType]可以被调用的所有限定条件也适用于这个方法。 
  /// All of the qualifications about when [dependOnInheritedWidgetOfExactType] can be called apply to this method as well.  
  InheritedWidget dependOnInheritedElement(InheritedElement ancestor, { Object aspect });

  ///获取最近的给定类型' T '的小部件,它必须是具体的[InheritedWidget]子类的类型,并将此构建上下文注册到该小部件,以便当该小部件更改时(或引入该类型的新小部件,或小部件消失),此构建上下文将重新构建,以便它可以从该小部件获取新值。
  /// Obtains the nearest widget of the given type `T`, which must be the type of a concrete [InheritedWidget] subclass, and registers this build context with that widget such that when that widget changes (or a new widget of that type is introduced, or the widget goes away), this build context is rebuilt so that it can obtain new values from that widget.
  ///
  ///这通常由' of() '静态方法隐式调用,例如[Theme.of]。
  /// This is typically called implicitly from `of()` static methods, e.g.[Theme.of].
  ///
  ///该方法不能从小部件构造函数或[State. conf]调用。initState]方法,因为如果继承的值发生变化,这些方法将不会被再次调用。为了确保小部件在继承的值改变时正确地更新自己,只能从构建方法、布局和绘制回调或从[State.didChangeDependencies]调用这个(直接或间接)。
  /// This method should not be called from widget constructors or from [State.    initState] methods, because those methods would not get called again if the inherited value were to change.     To ensure that the widget correctly updates itself when the inherited value changes, only call this (directly or indirectly) from build methods, layout and paint callbacks, or from [State.didChangeDependencies].
  ///
  ///不应该从[State.]调用此方法。因为元素树在那个时候不再稳定。要从该方法引用一个祖先,请在[State.didChangeDependencies]中保存对祖先的引用。
  ///从[State.deactivate]中使用这个方法是安全的,当小部件从树中移除时,这个方法就会被调用。
  /// This method should not be called from [State.    dispose] because the element tree is no longer stable at that time.     To refer to an ancestor from that method, save a reference to the ancestor in [State.didChangeDependencies].
  /// It is safe to use this method from [State.deactivate], which is called whenever the widget is removed from the tree.
  ///
  ///也可以从交互事件处理程序(例如,手势回调)或计时器调用此方法,如果该值不会被缓存并在以后重用,则只获取一次该值。
  /// It is also possible to call this method from interaction event handlers (e.g. gesture callbacks) or timers, to obtain a value once, if that value is not going to be cached and reused later.
  ///
  ///调用这个方法是O(1)和一个小的常数因子,但会导致小部件被更频繁地重建。
  /// Calling this method is O(1) with a small constant factor, but will lead to the widget being rebuilt more often.
  ///
  ///一旦一个小部件通过调用这个方法注册了一个特定类型的依赖项,它将被重新构建,并且[State. conf]每当与该小部件相关的更改发生时,都会调用didChangeDependencies],直到下次小部件或其祖先之一被移动时(例如,因为添加或删除了一个祖先)。
  /// Once a widget registers a dependency on a particular type by calling this method, it will be rebuilt, and [State.    didChangeDependencies] will be called, whenever changes occur relating to that widget until the next time the widget or one of its ancestors is moved (for example, because an ancestor is added or removed).
  ///
  ///只有当' T '是一个支持部分更新的[InheritedWidget]子类时,才会使用[aspect]参数,比如[InheritedModel]。它指定此上下文所依赖的继承小部件的哪个“方面”。
  /// The [aspect] parameter is only used when `T` is an [InheritedWidget] subclasses that supports partial updates, like [InheritedModel].     It specifies what "aspect" of the inherited widget this context depends on.
  T? dependOnInheritedWidgetOfExactType<T extends InheritedWidget>({ Object? aspect });

  ///获取与给定类型' T '的最近的小部件对应的元素,该小部件必须是具体的[InheritedWidget]子类的类型。
  /// Obtains the element corresponding to the nearest widget of the given type `T`, which must be the type of a concrete [InheritedWidget] subclass.
  ///
  ///如果没有找到这样的元素则返回null。
  /// Returns null if no such element is found.
  ///
  ///调用此方法是O(1)与一个小常数因子。
  /// Calling this method is O(1) with a small constant factor.
  ///
  ///该方法不像[dependOnInheritedWidgetOfExactType]那样与目标建立关系。
  /// This method does not establish a relationship with the target in the way that [dependOnInheritedWidgetOfExactType] does.
  ///
  ///不应该从[State.]调用此方法。因为元素树在那个时候不再稳定。要从该方法引用一个祖先,请在[State.didChangeDependencies]中调用[dependOnInheritedWidgetOfExactType]来保存对祖先的引用。从[State.deactivate]中使用这个方法是安全的,每当小部件从树中移除时,就会调用这个方法。
  /// This method should not be called from [State.dispose] because the element tree is no longer stable at that time. To refer to an ancestor from that method, save a reference to the ancestor by calling [dependOnInheritedWidgetOfExactType] in [State.didChangeDependencies]. It is safe to use this method from [State.deactivate], which is called whenever the widget is removed from the tree.
  InheritedElement? getElementForInheritedWidgetOfExactType<T extends InheritedWidget>();

  ///返回给定类型' T '的最近的祖先小部件,它必须是一个具体的[widget]子类的类型。
  /// Returns the nearest ancestor widget of the given type `T`, which must be the type of a concrete [Widget] subclass.
  ///
  ///一般来说,[dependOnInheritedWidgetOfExactType]更有用,因为继承的小部件会在更改时触发消费者重新构建。此方法适用于交互事件处理程序(例如,手势回调)或执行一次性任务,例如断言您是否拥有特定类型的小部件作为祖先。Widget的构建方法的返回值不应该依赖于此方法返回的值,因为如果此方法的返回值发生变化,构建上下文将不会重新构建。这可能会导致构建方法中使用的数据发生变化,但小部件没有被重新构建。
  /// In general, [dependOnInheritedWidgetOfExactType] is more useful, since inherited widgets will trigger consumers to rebuild when they change.  This method is appropriate when used in interaction event handlers (e.g. gesture callbacks) or for performing one-off tasks such as asserting that you have or don't have a widget of a specific type as an ancestor.  The return value of a Widget's build method should not depend on the value returned by this method, because the build context will not rebuild if the return value of this method changes.  This could lead to a situation where data used in the build method changes, but the widget is not rebuilt.
  ///
  ///调用这个方法是相对昂贵的(O(N)在树的深度)。只有在这个小部件到所需祖先的距离已知很小且有界时才调用此方法。
  /// Calling this method is relatively expensive (O(N) in the depth of the tree).  Only call this method if the distance from this widget to the desired ancestor is known to be small and bounded.
  ///
  ///该方法不能从[State.deactivate]或[State.deactivate]调用。因为小部件树在那个时候不再稳定。要从这些方法中引用一个祖先,请在[State.didChangeDependencies]中调用[find祖宗widgetofexacttype]来保存对祖先的引用。
  /// This method should not be called from [State.deactivate] or [State. dispose] because the widget tree is no longer stable at that time.  To refer to an ancestor from one of those methods, save a reference to the ancestor by calling [findAncestorWidgetOfExactType] in [State.didChangeDependencies].
  ///
  ///如果请求类型的小部件没有出现在此上下文的祖先中,则返回null。
  /// Returns null if a widget of the requested type does not appear in the ancestors of this context.
  T? findAncestorWidgetOfExactType<T extends Widget>();

  ///返回最近的祖先部件[StatefulWidget]的[State]对象,该部件是给定类型' T '的实例。
  /// Returns the [State] object of the nearest ancestor [StatefulWidget] widget that is an instance of the given type `T`.
  ///
  ///不应该从构建方法中使用,因为如果该方法返回的值发生变化,构建上下文将不会被重新构建。
  /// This should not be used from build methods, because the build context will not be rebuilt if the value that would be returned by this method changes.
  ///
  ///一般来说,[dependOnInheritedWidgetOfExactType]更适合这种情况。此方法对于一次性更改祖先小部件的状态非常有用,例如,导致祖先滚动列表将构建上下文的小部件滚动到视图中,或移动焦点以响应用户交互。
  /// In general, [dependOnInheritedWidgetOfExactType] is more appropriate for such cases. This method is useful for changing the state of an ancestor widget in a one-off manner, for example, to cause an ancestor scrolling list to scroll this build context's widget into view, or to move the focus in response to user interaction.
  ///
  ///但是,一般情况下,考虑使用回调来触发祖先中的有状态更改,而不是使用此方法所暗示的命令式样式。这通常会导致代码更具可维护性和可重用性,因为它将小部件彼此分离。
  /// In general, though, consider using a callback that triggers a stateful change in the ancestor rather than using the imperative style implied by this method. This will usually lead to more maintainable and reusable code since it decouples widgets from each other.
  ///
  ///调用这个方法是相对昂贵的(O(N)在树的深度)。只有在这个小部件到所需祖先的距离已知很小且有界时才调用此方法。
  /// Calling this method is relatively expensive (O(N) in the depth of the tree). Only call this method if the distance from this widget to the desired ancestor is known to be small and bounded.
  ///
  ///该方法不能从[State.deactivate]或[State.deactivate]调用。因为小部件树在那个时候不再稳定。要从这些方法中引用一个祖先,请通过调用[State.didChangeDependencies]中的[find祖宗stateoftype]来保存对祖先的引用。
  /// This method should not be called from [State.deactivate] or [State.dispose] because the widget tree is no longer stable at that time. To refer to an ancestor from one of those methods, save a reference to the ancestor by calling [findAncestorStateOfType] in [State.didChangeDependencies].
  ///
  /// {@tool snippet}
  ///
  /// ```dart
  /// ScrollableState? scrollable = context.findAncestorStateOfType<ScrollableState>();
  /// ```
  /// {@end-tool}
  T? findAncestorStateOfType<T extends State>();

  ///返回最远祖先[StatefulWidget]小部件的[State]对象,该小部件是给定类型' T '的实例。
  /// Returns the [State] object of the furthest ancestor [StatefulWidget] widget that is an instance of the given type `T`.
  ///
  ///与[findancestry orstateoftype]的功能相同,但一直访问后续的祖先,直到没有' T '的类型实例。
  ///返回找到的最后一个。
  /// Functions the same way as [findAncestorStateOfType] but keeps visiting subsequent ancestors until there are none of the type instance of `T` remaining.
  /// Then returns the last one found.
  ///
  ///这个操作也是O(N),尽管N是整个小部件树而不是子树。
  /// This operation is O(N) as well though N is the entire widget tree rather than a subtree.
  T? findRootAncestorStateOfType<T extends State>();

  ///返回最近的祖先[RenderObjectWidget]小部件的[RenderObject]对象,该小部件是给定类型' T '的实例。
  /// Returns the [RenderObject] object of the nearest ancestor [RenderObjectWidget] widget that is an instance of the given type `T`.
  ///
  ///不应该从构建方法中使用,因为如果该方法返回的值发生变化,构建上下文将不会被重新构建。
  ///一般来说,[dependOnInheritedWidgetOfExactType]更适合这种情况。这种方法只在一些复杂的情况下有用,比如小部件需要导致一个祖先改变它的布局或绘制行为。例如,它被[Material]使用,这样[InkWell]小部件就可以触发[Material]实际渲染对象上的墨水飞溅。
  /// This should not be used from build methods, because the build context will not be rebuilt if the value that would be returned by this method changes.
  /// In general, [dependOnInheritedWidgetOfExactType] is more appropriate for such cases. This method is useful only in esoteric cases where a widget needs to cause an ancestor to change its layout or paint behavior. For example, it is used by [Material] so that [InkWell] widgets can trigger the ink splash on the [Material]'s actual render object.
  ///
  ///调用这个方法是相对昂贵的(O(N)在树的深度)。只有在这个小部件到所需祖先的距离已知很小且有界时才调用此方法。
  /// Calling this method is relatively expensive (O(N) in the depth of the tree). Only call this method if the distance from this widget to the desired ancestor is known to be small and bounded.
  ///
  ///该方法不能从[State.deactivate]或[State.deactivate]调用。因为小部件树在那个时候不再稳定。要从这些方法中引用一个祖先,请在[State.didChangeDependencies]中调用[find祖宗renderobjectoftype]来保存对祖先的引用。
  /// This method should not be called from [State.deactivate] or [State.dispose] because the widget tree is no longer stable at that time. To refer to an ancestor from one of those methods, save a reference to the ancestor by calling [findAncestorRenderObjectOfType] in [State.didChangeDependencies].
  T? findAncestorRenderObjectOfType<T extends RenderObject>();

  ///遍历祖先链,从这个构建上下文的小部件的父组件开始,调用每个祖先的参数。回调被赋予一个对祖先小部件对应的[Element]对象的引用。遍历在到达根小部件或回调返回false时停止。回调不能返回null。
  /// Walks the ancestor chain, starting with the parent of this build context's widget, invoking the argument for each ancestor. The callback is given a reference to the ancestor widget's corresponding [Element] object. The walk stops when it reaches the root widget or when the callback returns false. The callback must not return null.
  ///
  ///这对于检查小部件树很有用。
  /// This is useful for inspecting the widget tree.
  ///
  ///调用这个方法是相对昂贵的(O(N)在树的深度)。
  /// Calling this method is relatively expensive (O(N) in the depth of the tree).
  ///
  ///该方法不能从[State.deactivate]或[State.deactivate]调用。因为元素树在那个时候不再稳定。要从这些方法中引用一个祖先,请调用[State.didChangeDependencies]中的[visit祖宗lements]来保存对祖先的引用。
  /// This method should not be called from [State.deactivate] or [State.dispose] because the element tree is no longer stable at that time. To refer to an ancestor from one of those methods, save a reference to the ancestor by calling [visitAncestorElements] in [State.didChangeDependencies].
  void visitAncestorElements(bool Function(Element element) visitor);

  ///遍历这个小部件的子部件。
  /// Walks the children of this widget.
  ///
  ///这对于在构建子代之后应用更改而不等待下一帧是有用的,特别是如果子代是已知的,特别是如果只有一个子代(就像对于[StatefulWidget]s或[StatelessWidget]s总是这样)。
  /// This is useful for applying changes to children after they are built without waiting for the next frame, especially if the children are known, and especially if there is exactly one child (as is always the case for [StatefulWidget]s or [StatelessWidget]s).
  ///
  ///对于与[StatelessWidget]s或[StatelessWidget]s (O(1)对应的构建上下文来说,调用这个方法非常便宜,因为只有一个孩子)。
  /// Calling this method is very cheap for build contexts that correspond to [StatefulWidget]s or [StatelessWidget]s (O(1), since there's only one child).
  ///
  ///调用此方法可能会导致构建上下文与[RenderObjectWidget]s (O(N) in number of child)相对应。
  /// Calling this method is potentially expensive for build contexts that correspond to [RenderObjectWidget]s (O(N) in the number of children).
  ///
  ///递归调用这个方法是非常昂贵的(O(N)在后代的数量),如果可能的话应该避免。通常,使用[InheritedWidget]并让后代向下拉数据要比使用[visitChildElements]递归地将数据向下推到后代要便宜得多。
  /// Calling this method recursively is extremely expensive (O(N) in the number of descendants), and should be avoided if possible.  Generally it is significantly cheaper to use an [InheritedWidget] and have the descendants pull data down, than it is to use [visitChildElements] recursively to push data down to them.
  void visitChildElements(ElementVisitor visitor);

  ///在给定的构建上下文开始冒泡此通知。
  /// Start bubbling this notification at the given build context.
  ///
  ///通知将被传递给任何[NotificationListener]小部件,这些小部件具有适当的类型参数,是给定[BuildContext]的祖先。
  /// The notification will be delivered to any [NotificationListener] widgets with the appropriate type parameters that are ancestors of the given [BuildContext].
  void dispatchNotification(Notification notification);

  ///返回与当前构建上下文相关的[Element]的描述。
  /// Returns a description of the [Element] associated with the current build context.
  ///
  ///“name”通常是类似于“The element being rebuild was”的东西。
  /// The `name` is typically something like "The element being rebuilt was".
  ///
  /// See also:
  ///
  /// * [Element.describeElements],可以用来描述一个元素列表。
  ///  * [Element.describeElements], which can be used to describe a list of elements.
  DiagnosticsNode describeElement(String name, {DiagnosticsTreeStyle style = DiagnosticsTreeStyle.errorProperty});

  ///返回与当前构建上下文相关的[Widget]的描述。
  /// Returns a description of the [Widget] associated with the current build context.
  ///
  ///“名称”通常是类似于“正在重建的小部件是”这样的东西。
  /// The `name` is typically something like "The widget being rebuilt was".
  DiagnosticsNode describeWidget(String name, {DiagnosticsTreeStyle style = DiagnosticsTreeStyle.errorProperty});

  ///添加当前构建上下文祖先树中缺少的特定类型小部件的描述。
  /// Adds a description of a specific type of widget missing from the current build context's ancestry tree.
  ///
  ///你可以在[debugCheckHasMaterial]中找到使用这个方法的例子。
  /// You can find an example of using this method in [debugCheckHasMaterial].
  List<DiagnosticsNode> describeMissingAncestor({ required Type expectedAncestorType });

  ///将所有权链的描述从一个特定的[Element]添加到错误报告中。
  /// Adds a description of the ownership chain from a specific [Element] to the error report.
  ///
  /// 所有权链用于调试元素的源代码。
  /// The ownership chain is useful for debugging the source of an element.


  DiagnosticsNode describeOwnershipChain(String name);
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,406评论 6 503
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,732评论 3 393
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,711评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,380评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,432评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,301评论 1 301
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,145评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,008评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,443评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,649评论 3 334
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,795评论 1 347
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,501评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,119评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,731评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,865评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,899评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,724评论 2 354

推荐阅读更多精彩内容