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

Create enum for service extensions in services library (#111412)

parent 11fdced5
...@@ -37,6 +37,7 @@ export 'src/services/raw_keyboard_macos.dart'; ...@@ -37,6 +37,7 @@ export 'src/services/raw_keyboard_macos.dart';
export 'src/services/raw_keyboard_web.dart'; export 'src/services/raw_keyboard_web.dart';
export 'src/services/raw_keyboard_windows.dart'; export 'src/services/raw_keyboard_windows.dart';
export 'src/services/restoration.dart'; export 'src/services/restoration.dart';
export 'src/services/service_extensions.dart';
export 'src/services/spell_check.dart'; export 'src/services/spell_check.dart';
export 'src/services/system_channels.dart'; export 'src/services/system_channels.dart';
export 'src/services/system_chrome.dart'; export 'src/services/system_chrome.dart';
......
...@@ -15,6 +15,7 @@ import 'binary_messenger.dart'; ...@@ -15,6 +15,7 @@ import 'binary_messenger.dart';
import 'hardware_keyboard.dart'; import 'hardware_keyboard.dart';
import 'message_codec.dart'; import 'message_codec.dart';
import 'restoration.dart'; import 'restoration.dart';
import 'service_extensions.dart';
import 'system_channels.dart'; import 'system_channels.dart';
import 'text_input.dart'; import 'text_input.dart';
...@@ -213,11 +214,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding { ...@@ -213,11 +214,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
assert(() { assert(() {
registerStringServiceExtension( registerStringServiceExtension(
// ext.flutter.evict value=foo.png will cause foo.png to be evicted from name: ServicesServiceExtensions.evict.name,
// the rootBundle cache and cause the entire image cache to be cleared.
// This is used by hot reload mode to clear out the cache of resources
// that have changed.
name: 'evict',
getter: () async => '', getter: () async => '',
setter: (String value) async { setter: (String value) async {
evict(value); evict(value);
......
// 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 services 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 ServicesServiceExtensions {
/// Name of service extension that, when called, will evict an image from the
/// rootBundle cache and cause the image cache to be cleared.
///
/// This is used by hot reload mode to clear out the cache of resources that
/// have changed. This service extension should be called with a String value
/// of the image path (e.g. foo.png).
///
/// See also:
///
/// * [ServicesBinding.initServiceExtensions], where the service extension is
/// registered.
evict,
}
...@@ -563,7 +563,7 @@ void main() { ...@@ -563,7 +563,7 @@ void main() {
}); });
expect(data, isTrue); expect(data, isTrue);
expect(completed, isFalse); expect(completed, isFalse);
result = await binding.testExtension('evict', <String, String>{'value': 'test'}); result = await binding.testExtension(ServicesServiceExtensions.evict.name, <String, String>{'value': 'test'});
expect(result, <String, String>{'value': ''}); expect(result, <String, String>{'value': ''});
expect(completed, isFalse); expect(completed, isFalse);
data = await rootBundle.loadStructuredData<bool>('test', (String value) async { data = await rootBundle.loadStructuredData<bool>('test', (String value) async {
......
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