Unverified Commit c51fba97 authored by creativecreatorormaybenot's avatar creativecreatorormaybenot Committed by GitHub

Improve lifecycle docs (#76021)

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