[flutter_tools] connect widget cache from frontend_server (#65951)
This commit is contained in:
@@ -433,21 +433,16 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
|
||||
registerServiceExtension(
|
||||
name: 'fastReassemble',
|
||||
callback: (Map<String, Object> params) async {
|
||||
final FastReassemblePredicate? fastReassemblePredicate = _debugFastReassembleMethod;
|
||||
_debugFastReassembleMethod = null;
|
||||
if (fastReassemblePredicate == null) {
|
||||
throw FlutterError('debugFastReassembleMethod must be set to use fastReassemble.');
|
||||
}
|
||||
void markElementsDirty(Element? element) {
|
||||
if (element == null) {
|
||||
return;
|
||||
}
|
||||
if (fastReassemblePredicate(element.widget)) {
|
||||
final String? className = params['className'] as String?;
|
||||
void markElementsDirty(Element element) {
|
||||
if (element.widget.runtimeType.toString() == className) {
|
||||
element.markNeedsBuild();
|
||||
}
|
||||
element.visitChildElements(markElementsDirty);
|
||||
}
|
||||
markElementsDirty(renderViewElement);
|
||||
if (renderViewElement != null) {
|
||||
markElementsDirty(renderViewElement!);
|
||||
}
|
||||
await endOfFrame;
|
||||
return <String, String>{'type': 'Success'};
|
||||
},
|
||||
@@ -1061,36 +1056,6 @@ void runApp(Widget app) {
|
||||
..scheduleWarmUpFrame();
|
||||
}
|
||||
|
||||
/// A function that should validate that the provided object is assignable to a
|
||||
/// given type.
|
||||
typedef FastReassemblePredicate = bool Function(Object);
|
||||
|
||||
/// Debug-only functionality used to perform faster hot reloads.
|
||||
///
|
||||
/// This field is set by expression evaluation in the flutter tool and is
|
||||
/// used to invalidate specific types of [Element]s. This setter
|
||||
/// should not be referenced in user code and is only public so that expression
|
||||
/// evaluation can be done in the context of an almost-arbitrary Dart library.
|
||||
///
|
||||
/// For example, expression evaluation might be performed with the following code:
|
||||
///
|
||||
/// ```dart
|
||||
/// (debugFastReassembleMethod=(Object x) => x is Foo)()
|
||||
/// ```
|
||||
///
|
||||
/// And then followed by a call to `ext.flutter.fastReassemble`. This will read
|
||||
/// the provided predicate and use it to mark specific elements dirty wherever
|
||||
/// [Element.widget] is a `Foo`. Afterwards, the internal field will be nulled
|
||||
/// out.
|
||||
FastReassemblePredicate? get debugFastReassembleMethod => _debugFastReassembleMethod;
|
||||
set debugFastReassembleMethod(FastReassemblePredicate? fastReassemblePredicate) {
|
||||
assert(() {
|
||||
_debugFastReassembleMethod = fastReassemblePredicate;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
FastReassemblePredicate? _debugFastReassembleMethod;
|
||||
|
||||
/// Print a string representation of the currently running app.
|
||||
void debugDumpApp() {
|
||||
assert(WidgetsBinding.instance != null);
|
||||
|
||||
@@ -740,8 +740,4 @@ void main() {
|
||||
|
||||
expect(brightnessValue, 'Brightness.light');
|
||||
});
|
||||
|
||||
test('Service extensions - fastReassemble', () async {
|
||||
expect(binding.testExtension('fastReassemble', <String, String>{}), throwsA(isA<FlutterError>()));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user