Commit 1d773ace authored by Remi Rousselet's avatar Remi Rousselet Committed by Michael Goderbauer

Make reassemble public (#26900)

parent e38efc89
...@@ -21,7 +21,6 @@ export 'package:flutter/foundation.dart' show ...@@ -21,7 +21,6 @@ export 'package:flutter/foundation.dart' show
protected, protected,
required, required,
visibleForTesting; visibleForTesting;
export 'package:flutter/foundation.dart' show FlutterError, debugPrint, debugPrintStack; export 'package:flutter/foundation.dart' show FlutterError, debugPrint, debugPrintStack;
export 'package:flutter/foundation.dart' show VoidCallback, ValueChanged, ValueGetter, ValueSetter; export 'package:flutter/foundation.dart' show VoidCallback, ValueChanged, ValueGetter, ValueSetter;
export 'package:flutter/foundation.dart' show DiagnosticLevel; export 'package:flutter/foundation.dart' show DiagnosticLevel;
...@@ -1030,23 +1029,15 @@ abstract class State<T extends StatefulWidget> extends Diagnosticable { ...@@ -1030,23 +1029,15 @@ abstract class State<T extends StatefulWidget> extends Diagnosticable {
@protected @protected
void didUpdateWidget(covariant T oldWidget) { } void didUpdateWidget(covariant T oldWidget) { }
/// Called whenever the application is reassembled during debugging, for /// {@macro flutter.widgets.reassemble}
/// example during hot reload.
///
/// This method should rerun any initialization logic that depends on global
/// state, for example, image loading from asset bundles (since the asset
/// bundle may have changed).
/// ///
/// In addition to this method being invoked, it is guaranteed that the /// In addition to this method being invoked, it is guaranteed that the
/// [build] method will be invoked when a reassemble is signaled. Most /// [build] method will be invoked when a reassemble is signaled. Most
/// widgets therefore do not need to do anything in the [reassemble] method. /// widgets therefore do not need to do anything in the [reassemble] method.
/// ///
/// This function will only be called during development. In release builds,
/// the `ext.flutter.reassemble` hook is not available, and so this code will
/// never execute.
///
/// See also: /// See also:
/// ///
/// * [Element.reassemble]
/// * [BindingBase.reassembleApplication] /// * [BindingBase.reassembleApplication]
/// * [Image], which uses this to reload images. /// * [Image], which uses this to reload images.
@protected @protected
...@@ -2467,7 +2458,7 @@ class BuildOwner { ...@@ -2467,7 +2458,7 @@ class BuildOwner {
try { try {
assert(root._parent == null); assert(root._parent == null);
assert(root.owner == this); assert(root.owner == this);
root._reassemble(); root.reassemble();
} finally { } finally {
Timeline.finishSync(); Timeline.finishSync();
} }
...@@ -2595,11 +2586,30 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ...@@ -2595,11 +2586,30 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
bool _active = false; bool _active = false;
/// {@template flutter.widgets.reassemble}
/// Called whenever the application is reassembled during debugging, for
/// example during hot reload.
///
/// This method should rerun any initialization logic that depends on global
/// state, for example, image loading from asset bundles (since the asset
/// bundle may have changed).
///
/// This function will only be called during development. In release builds,
/// the `ext.flutter.reassemble` hook is not available, and so this code will
/// never execute.
/// {@endtemplate}
///
/// See also:
///
/// * [State.reassemble]
/// * [BindingBase.reassembleApplication]
/// * [Image], which uses this to reload images.
@mustCallSuper @mustCallSuper
void _reassemble() { @protected
void reassemble() {
markNeedsBuild(); markNeedsBuild();
visitChildren((Element child) { visitChildren((Element child) {
child._reassemble(); child.reassemble();
}); });
} }
...@@ -3817,9 +3827,9 @@ class StatefulElement extends ComponentElement { ...@@ -3817,9 +3827,9 @@ class StatefulElement extends ComponentElement {
State<StatefulWidget> _state; State<StatefulWidget> _state;
@override @override
void _reassemble() { void reassemble() {
state.reassemble(); state.reassemble();
super._reassemble(); super.reassemble();
} }
@override @override
......
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