Unverified Commit c10164c4 authored by Kenzie Davisson's avatar Kenzie Davisson Committed by GitHub

Create consts for service extension names so they can be accessed from tooling (#110876)

parent 2b373903
......@@ -18,6 +18,7 @@ import 'focus_manager.dart';
import 'framework.dart';
import 'platform_menu_bar.dart';
import 'router.dart';
import 'service_extensions.dart';
import 'widget_inspector.dart';
export 'dart:ui' show AppLifecycleState, Locale;
......@@ -360,7 +361,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
if (!kReleaseMode) {
registerServiceExtension(
name: 'debugDumpApp',
name: WidgetsServiceExtensions.debugDumpApp.name,
callback: (Map<String, String> parameters) async {
final String data = _debugDumpAppString();
return <String, Object>{
......@@ -371,7 +372,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
if (!kIsWeb) {
registerBoolServiceExtension(
name: 'showPerformanceOverlay',
name: WidgetsServiceExtensions.showPerformanceOverlay.name,
getter: () =>
Future<bool>.value(WidgetsApp.showPerformanceOverlayOverride),
setter: (bool value) {
......@@ -385,7 +386,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
}
registerServiceExtension(
name: 'didSendFirstFrameEvent',
name: WidgetsServiceExtensions.didSendFirstFrameEvent.name,
callback: (_) async {
return <String, dynamic>{
// This is defined to return a STRING, not a boolean.
......@@ -396,10 +397,8 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
},
);
// This returns 'true' when the first frame is rasterized, and the trace
// event 'Rasterized first useful frame' is sent out.
registerServiceExtension(
name: 'didSendFirstFrameRasterizedEvent',
name: WidgetsServiceExtensions.didSendFirstFrameRasterizedEvent.name,
callback: (_) async {
return <String, dynamic>{
// This is defined to return a STRING, not a boolean.
......@@ -411,7 +410,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
);
registerServiceExtension(
name: 'fastReassemble',
name: WidgetsServiceExtensions.fastReassemble.name,
callback: (Map<String, Object> params) async {
// This mirrors the implementation of the 'reassemble' callback registration
// in lib/src/foundation/binding.dart, but with the extra binding config used
......@@ -429,7 +428,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
// Expose the ability to send Widget rebuilds as [Timeline] events.
registerBoolServiceExtension(
name: 'profileWidgetBuilds',
name: WidgetsServiceExtensions.profileWidgetBuilds.name,
getter: () async => debugProfileBuildsEnabled,
setter: (bool value) async {
if (debugProfileBuildsEnabled != value) {
......@@ -438,7 +437,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
},
);
registerBoolServiceExtension(
name: 'profileUserWidgetBuilds',
name: WidgetsServiceExtensions.profileUserWidgetBuilds.name,
getter: () async => debugProfileBuildsEnabledUserWidgets,
setter: (bool value) async {
if (debugProfileBuildsEnabledUserWidgets != value) {
......@@ -450,7 +449,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
assert(() {
registerBoolServiceExtension(
name: 'debugAllowBanner',
name: WidgetsServiceExtensions.debugAllowBanner.name,
getter: () => Future<bool>.value(WidgetsApp.debugAllowBannerOverride),
setter: (bool value) {
if (WidgetsApp.debugAllowBannerOverride == value) {
......@@ -461,20 +460,6 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
},
);
// This service extension is deprecated and will be removed by 12/1/2018.
// Use ext.flutter.inspector.show instead.
registerBoolServiceExtension(
name: 'debugWidgetInspector',
getter: () async => WidgetsApp.debugShowWidgetInspectorOverride,
setter: (bool value) {
if (WidgetsApp.debugShowWidgetInspectorOverride == value) {
return Future<void>.value();
}
WidgetsApp.debugShowWidgetInspectorOverride = value;
return _forceRebuild();
},
);
WidgetInspectorService.instance.initServiceExtensions(registerServiceExtension);
return true;
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Service extension constants for the widgets library.
///
/// These constants will be used when registering service extensions in the
/// framework, and they will also be used by tools and services that call these
/// service extensions.
///
/// The String value for each of these extension names should be accessed by
/// calling the `.name` property on the enum value.
enum WidgetsServiceExtensions {
/// Name of service extension that, when called, will output a string
/// representation of this app's widget tree to console.
///
/// See also:
///
/// * [WidgetsBinding.initServiceExtensions], where the service extension is
/// registered.
debugDumpApp,
/// Name of service extension that, when called, will overlay a performance
/// graph on top of this app.
///
/// See also:
///
/// * [WidgetsApp.showPerformanceOverlayOverride], which is the flag
/// that this service extension exposes.
/// * [WidgetsBinding.initServiceExtensions], where the service extension is
/// registered.
showPerformanceOverlay,
/// Name of service extension that, when called, will return whether the first
/// 'Flutter.Frame' event has been reported on the Extension stream.
///
/// See also:
///
/// * [WidgetsBinding.initServiceExtensions], where the service extension is
/// registered.
didSendFirstFrameEvent,
/// Name of service extension that, when called, will return whether the first
/// frame has been rasterized and the trace event 'Rasterized first useful
/// frame' has been sent out.
///
/// See also:
///
/// * [WidgetsBinding.initServiceExtensions], where the service extension is
/// registered.
didSendFirstFrameRasterizedEvent,
/// Name of service extension that, when called, will reassemble the
/// application.
///
/// See also:
///
/// * [WidgetsBinding.initServiceExtensions], where the service extension is
/// registered.
fastReassemble,
/// Name of service extension that, when called, will change the value of
/// [debugProfileBuildsEnabled], which adds [Timeline] events for every widget
/// built.
///
/// See also:
///
/// * [debugProfileBuildsEnabled], which is the flag that this service extension
/// exposes.
/// * [WidgetsBinding.initServiceExtensions], where the service extension is
/// registered.
profileWidgetBuilds,
/// Name of service extension that, when called, will change the value of
/// [debugProfileBuildsEnabledUserWidgets], which adds [Timeline] events for
/// every user-created widget built.
///
/// See also:
/// * [debugProfileBuildsEnabledUserWidgets], which is the flag that this
/// service extension exposes.
/// * [WidgetsBinding.initServiceExtensions], where the service extension is
/// registered.
profileUserWidgetBuilds,
/// Name of service extension that, when called, will change the value of
/// [WidgetsApp.debugAllowBannerOverride], which controls the visibility of the
/// debug banner for debug mode apps.
///
/// See also:
///
/// * [WidgetsApp.debugAllowBannerOverride], which is the flag that this service
/// extension exposes.
/// * [WidgetsBinding.initServiceExtensions], where the service extension is
/// registered.
debugAllowBanner,
}
......@@ -116,6 +116,7 @@ export 'src/widgets/scrollbar.dart';
export 'src/widgets/selectable_region.dart';
export 'src/widgets/selection_container.dart';
export 'src/widgets/semantics_debugger.dart';
export 'src/widgets/service_extensions.dart';
export 'src/widgets/shared_app_data.dart';
export 'src/widgets/shortcuts.dart';
export 'src/widgets/single_child_scroll_view.dart';
......
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