1. override
void initServiceExtensions()

Called when the binding is initialized, to register service extensions.

Bindings that want to expose service extensions should overload this method to register them using calls to registerSignalServiceExtension, registerBoolServiceExtension, registerNumericServiceExtension, and registerServiceExtension (in increasing order of complexity).

Implementations of this method must call their superclass implementation.

Service extensions are only exposed when the observatory is included in the build, which should only happen in checked mode and in profile mode.

See also:

Source

@override
void initServiceExtensions() {
  super.initServiceExtensions();
  registerStringServiceExtension(
    // ext.flutter.evict value=foo.png will cause foo.png to be evicted from 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.
    // TODO(ianh): find a way to only evict affected images, not all images
    name: 'evict',
    getter: () => '',
    setter: (String value) {
      rootBundle.evict(value);
      imageCache.clear();
    }
  );
}