Commit cd084005 authored by Eric Seidel's avatar Eric Seidel

Merge pull request #3470 from eseidelGoogle/master

Add a service extension for toggling the PerformanceOverlay
parents b7af64ee 898b3ce8
......@@ -92,6 +92,8 @@ class WidgetsApp extends StatefulWidget {
/// representative of what will happen in release mode.
final bool debugShowCheckedModeBanner;
static bool showPerformanceOverlayOverride = false;
@override
WidgetsAppState<WidgetsApp> createState() => new WidgetsAppState<WidgetsApp>();
}
......@@ -186,7 +188,7 @@ class WidgetsAppState<T extends WidgetsApp> extends State<T> implements BindingO
child: result
);
}
if (config.showPerformanceOverlay) {
if (config.showPerformanceOverlay || WidgetsApp.showPerformanceOverlayOverride) {
result = new Stack(
children: <Widget>[
result,
......
......@@ -10,6 +10,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'app.dart';
import 'framework.dart';
export 'dart:ui' show AppLifecycleState, Locale;
......@@ -52,6 +53,22 @@ class WidgetFlutterBinding extends BindingBase with Scheduler, Gesturer, Service
ui.window.onAppLifecycleStateChanged = handleAppLifecycleStateChanged;
}
@override
void initServiceExtensions() {
super.initServiceExtensions();
registerBoolServiceExtension(
name: 'showPerformanceOverlay',
getter: () => WidgetsApp.showPerformanceOverlayOverride,
setter: (bool value) {
if (WidgetsApp.showPerformanceOverlayOverride == value)
return;
WidgetsApp.showPerformanceOverlayOverride = value;
buildOwner.reassemble(renderViewElement);
}
);
}
/// The one static instance of this class.
///
/// Only valid after the WidgetFlutterBinding constructor) has been called.
......@@ -113,13 +130,13 @@ class WidgetFlutterBinding extends BindingBase with Scheduler, Gesturer, Service
container: renderView,
debugShortDescription: '[root]',
child: app
).attachToRenderTree(buildOwner, _renderViewElement);
).attachToRenderTree(buildOwner, renderViewElement);
beginFrame();
}
@override
void reassembleApplication() {
buildOwner.reassemble(_renderViewElement);
buildOwner.reassemble(renderViewElement);
super.reassembleApplication();
}
}
......
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