Improve lifecycle docs (#76021)
This commit is contained in:
committed by
GitHub
parent
ba58ad0385
commit
c51fba9736
@@ -87,6 +87,9 @@ class AbstractNode {
|
||||
/// Subclasses with children should override this method to first call their
|
||||
/// inherited [attach] method, and then [attach] all their children to the
|
||||
/// same [owner].
|
||||
///
|
||||
/// Implementations of this method should start with a call to the inherited
|
||||
/// method, as in `super.attach(owner)`.
|
||||
@mustCallSuper
|
||||
void attach(covariant Object owner) {
|
||||
assert(owner != null);
|
||||
@@ -101,6 +104,9 @@ class AbstractNode {
|
||||
///
|
||||
/// Subclasses with children should override this method to first call their
|
||||
/// inherited [detach] method, and then [detach] all their children.
|
||||
///
|
||||
/// Implementations of this method should end with a call to the inherited
|
||||
/// method, as in `super.detach()`.
|
||||
@mustCallSuper
|
||||
void detach() {
|
||||
assert(_owner != null);
|
||||
|
||||
@@ -2583,8 +2583,8 @@ abstract class RenderBox extends RenderObject {
|
||||
/// object you can determine the [PointerDownEvent]'s position in local coordinates.
|
||||
/// (This is useful because [PointerEvent.position] is in global coordinates.)
|
||||
///
|
||||
/// If you override this, consider calling [debugHandleEvent] as follows, so
|
||||
/// that you can support [debugPaintPointersEnabled]:
|
||||
/// Implementations of this method should call [debugHandleEvent] as follows,
|
||||
/// so that they support [debugPaintPointersEnabled]:
|
||||
///
|
||||
/// ```dart
|
||||
/// @override
|
||||
|
||||
@@ -242,8 +242,8 @@ abstract class ViewportOffset extends ChangeNotifier {
|
||||
/// the [State] base class calls [debugFillDescription] to collect useful
|
||||
/// information from subclasses to incorporate into its return value.
|
||||
///
|
||||
/// If you override this, make sure to start your method with a call to
|
||||
/// `super.debugFillDescription(description)`.
|
||||
/// Implementations of this method should start with a call to the inherited
|
||||
/// method, as in `super.debugFillDescription(description)`.
|
||||
@mustCallSuper
|
||||
void debugFillDescription(List<String> description) {
|
||||
if (hasPixels) {
|
||||
|
||||
@@ -979,8 +979,8 @@ abstract class State<T extends StatefulWidget> with Diagnosticable {
|
||||
/// following this method, and [BuildContext.dependOnInheritedWidgetOfExactType] can
|
||||
/// be used there.
|
||||
///
|
||||
/// If you override this, make sure your method starts with a call to
|
||||
/// super.initState().
|
||||
/// Implementations of this method should start with a call to the inherited
|
||||
/// method, as in `super.initState()`.
|
||||
@protected
|
||||
@mustCallSuper
|
||||
void initState() {
|
||||
@@ -1003,8 +1003,8 @@ abstract class State<T extends StatefulWidget> with Diagnosticable {
|
||||
///
|
||||
/// {@macro flutter.widgets.State.initState}
|
||||
///
|
||||
/// If you override this, make sure your method starts with a call to
|
||||
/// super.didUpdateWidget(oldWidget).
|
||||
/// Implementations of this method should start with a call to the inherited
|
||||
/// method, as in `super.didUpdateWidget(oldWidget)`.
|
||||
@mustCallSuper
|
||||
@protected
|
||||
void didUpdateWidget(covariant T oldWidget) { }
|
||||
@@ -1147,8 +1147,8 @@ abstract class State<T extends StatefulWidget> with Diagnosticable {
|
||||
/// this object and other elements in the tree (e.g. if you have provided an
|
||||
/// ancestor with a pointer to a descendant's [RenderObject]).
|
||||
///
|
||||
/// If you override this, make sure to end your method with a call to
|
||||
/// super.deactivate().
|
||||
/// Implementations of this method should end with a call to the inherited
|
||||
/// method, as in `super.deactivate()`.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
@@ -1171,8 +1171,8 @@ abstract class State<T extends StatefulWidget> with Diagnosticable {
|
||||
///
|
||||
/// {@macro flutter.widgets.State.initState}
|
||||
///
|
||||
/// If you override this, make sure to end your method with a call to
|
||||
/// super.dispose().
|
||||
/// Implementations of this method should end with a call to the inherited
|
||||
/// method, as in `super.dispose()`.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
@@ -3406,6 +3406,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
/// [update], [visitChildren], [RenderObjectElement.insertRenderObjectChild],
|
||||
/// [RenderObjectElement.moveRenderObjectChild], and
|
||||
/// [RenderObjectElement.removeRenderObjectChild].
|
||||
///
|
||||
/// Implementations of this method should start with a call to the inherited
|
||||
/// method, as in `super.mount(parent, newSlot)`.
|
||||
@mustCallSuper
|
||||
void mount(Element? parent, dynamic newSlot) {
|
||||
assert(_lifecycleState == _ElementLifecycle.initial);
|
||||
@@ -3725,6 +3728,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
/// lifecycle state). Instead, the framework calls [mount] in that situation.
|
||||
///
|
||||
/// See the lifecycle documentation for [Element] for additional information.
|
||||
///
|
||||
/// Implementations of this method should start with a call to the inherited
|
||||
/// method, as in `super.activate()`.
|
||||
@mustCallSuper
|
||||
void activate() {
|
||||
assert(_lifecycleState == _ElementLifecycle.inactive);
|
||||
@@ -3756,6 +3762,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
/// This is (indirectly) called by [deactivateChild].
|
||||
///
|
||||
/// See the lifecycle documentation for [Element] for additional information.
|
||||
///
|
||||
/// Implementations of this method should end with a call to the inherited
|
||||
/// method, as in `super.deactivate()`.
|
||||
@mustCallSuper
|
||||
void deactivate() {
|
||||
assert(_lifecycleState == _ElementLifecycle.active);
|
||||
@@ -3794,6 +3803,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
/// the tree again.
|
||||
///
|
||||
/// See the lifecycle documentation for [Element] for additional information.
|
||||
///
|
||||
/// Implementations of this method should end with a call to the inherited
|
||||
/// method, as in `super.unmount()`.
|
||||
@mustCallSuper
|
||||
void unmount() {
|
||||
assert(_lifecycleState == _ElementLifecycle.inactive);
|
||||
|
||||
@@ -152,8 +152,8 @@ abstract class Notification {
|
||||
/// the [Notification] base class calls [debugFillDescription] to collect
|
||||
/// useful information from subclasses to incorporate into its return value.
|
||||
///
|
||||
/// If you override this, make sure to start your method with a call to
|
||||
/// `super.debugFillDescription(description)`.
|
||||
/// Implementations of this method should start with a call to the inherited
|
||||
/// method, as in `super.debugFillDescription(description)`.
|
||||
@protected
|
||||
@mustCallSuper
|
||||
void debugFillDescription(List<String> description) { }
|
||||
|
||||
@@ -255,8 +255,8 @@ class ScrollController extends ChangeNotifier {
|
||||
/// the [ScrollController] base class calls [debugFillDescription] to collect
|
||||
/// useful information from subclasses to incorporate into its return value.
|
||||
///
|
||||
/// If you override this, make sure to start your method with a call to
|
||||
/// `super.debugFillDescription(description)`.
|
||||
/// Implementations of this method should start with a call to the inherited
|
||||
/// method, as in `super.debugFillDescription(description)`.
|
||||
@mustCallSuper
|
||||
void debugFillDescription(List<String> description) {
|
||||
if (debugLabel != null)
|
||||
|
||||
Reference in New Issue
Block a user