From 57dc5f294b8a62618840d4f27fe645c5dc91cc89 Mon Sep 17 00:00:00 2001 From: Gary Qian Date: Thu, 11 Mar 2021 15:50:07 -0800 Subject: [PATCH] Rename 'moduleName' to 'componentName' (#77789) --- .../lib/src/services/deferred_component.dart | 28 +++++++++---------- .../lib/src/services/system_channels.dart | 19 ++++++------- .../services/deferred_component_test.dart | 8 +++--- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/packages/flutter/lib/src/services/deferred_component.dart b/packages/flutter/lib/src/services/deferred_component.dart index 7d58990ffd..ad6f74e62d 100644 --- a/packages/flutter/lib/src/services/deferred_component.dart +++ b/packages/flutter/lib/src/services/deferred_component.dart @@ -6,7 +6,7 @@ import 'dart:async'; import 'system_channels.dart'; -/// Manages the installation and loading of deferred component modules. +/// Manages the installation and loading of deferred components. /// /// Deferred components allow Flutter applications to download precompiled AOT /// dart code and assets at runtime, reducing the install size of apps and @@ -25,12 +25,12 @@ class DeferredComponent { // prevents instantiation and extension. DeferredComponent._(); - // TODO(garyq): We should eventually expand this to install modules by loadingUnitId - // as well as moduleName, but currently, loadingUnitId is opaque to the dart code + // TODO(garyq): We should eventually expand this to install components by loadingUnitId + // as well as componentName, but currently, loadingUnitId is opaque to the dart code // so this is not possible. The API has been left flexible to allow adding // loadingUnitId as a parameter. - /// Requests that an assets-only deferred component identified by the [moduleName] + /// Requests that an assets-only deferred component identified by the [componentName] /// be downloaded and installed. /// /// This method returns a Future that will complete when the feature is @@ -45,14 +45,14 @@ class DeferredComponent { /// library loading process. For example: /// /// ```dart - /// import 'split_module.dart' deferred as SplitModule; + /// import 'split_component.dart' deferred as SplitComponent; /// ... - /// SplitModule.loadLibrary(); + /// SplitComponent.loadLibrary(); /// ``` /// - /// This method will not load associated dart libraries contained in the dynamic - /// feature module, though it will download the files necessary and subsequent - /// calls to `loadLibrary()` to load will complete faster. + /// This method will not load associated dart libraries contained in the component, + /// though it will download the files necessary and subsequent calls to `loadLibrary()` + /// to load will complete faster. /// /// Assets installed by this method may be accessed in the same way as any other /// local asset by providing a string path to the asset. @@ -63,14 +63,14 @@ class DeferredComponent { /// * [loadLibrary](https://api.dart.dev/dart-mirrors/LibraryDependencyMirror/loadLibrary.html), /// the dart method to trigger the installation of the corresponding deferred component that /// contains the dart library. - static Future installDeferredComponent({required String moduleName}) async { + static Future installDeferredComponent({required String componentName}) async { await SystemChannels.deferredComponent.invokeMethod( 'installDeferredComponent', - { 'loadingUnitId': -1, 'moduleName': moduleName }, + { 'loadingUnitId': -1, 'componentName': componentName }, ); } - /// Requests that a deferred component identified by the [moduleName] be + /// Requests that a deferred component identified by the [componentName] be /// uninstalled. /// /// Since uninstallation typically requires significant disk i/o, this method only @@ -91,10 +91,10 @@ class DeferredComponent { /// * [loadLibrary](https://api.dart.dev/dart-mirrors/LibraryDependencyMirror/loadLibrary.html), /// the dart method to trigger the installation of the corresponding deferred component that /// contains the dart library. - static Future uninstallDeferredComponent({required String moduleName}) async { + static Future uninstallDeferredComponent({required String componentName}) async { await SystemChannels.deferredComponent.invokeMethod( 'uninstallDeferredComponent', - { 'loadingUnitId': -1, 'moduleName': moduleName }, + { 'loadingUnitId': -1, 'componentName': componentName }, ); } } diff --git a/packages/flutter/lib/src/services/system_channels.dart b/packages/flutter/lib/src/services/system_channels.dart index e0e08fe88b..46be180631 100644 --- a/packages/flutter/lib/src/services/system_channels.dart +++ b/packages/flutter/lib/src/services/system_channels.dart @@ -324,17 +324,16 @@ class SystemChannels { /// [OptionalMethodChannel.invokeMethod]): /// /// * `installDeferredComponent`: Requests that a deferred component identified by - /// the provided loadingUnitId or moduleName be downloaded and installed. - /// Providing a loadingUnitId with null moduleName will install a dynamic - /// feature module that includes the desired loading unit. If a moduleName - /// is provided, then the deferred component with the moduleName will be installed. - /// This method returns a future that will not be completed until the - /// feature is fully installed and ready to use. When an error occurs, the - /// future will complete an error. Calling `loadLibrary()` on a deferred - /// imported library is equivalent to calling this method with a - /// loadingUnitId and null moduleName. + /// the provided loadingUnitId or componentName be downloaded and installed. + /// Providing a loadingUnitId with null componentName will install a component that + /// includes the desired loading unit. If a componentName is provided, then the + /// deferred component with the componentName will be installed. This method + /// returns a future that will not be completed until the feature is fully installed + /// and ready to use. When an error occurs, the future will complete an error. + /// Calling `loadLibrary()` on a deferred imported library is equivalent to calling + /// this method with a loadingUnitId and null componentName. /// * `uninstallDeferredComponent`: Requests that a deferred component identified by - /// the provided loadingUnitId or moduleName be uninstalled. Since + /// the provided loadingUnitId or componentName be uninstalled. Since /// uninstallation typically requires significant disk i/o, this method only /// signals the intent to uninstall. Actual uninstallation (eg, removal of /// assets and files) may occur at a later time. However, once uninstallation diff --git a/packages/flutter/test/services/deferred_component_test.dart b/packages/flutter/test/services/deferred_component_test.dart index 49b85dee7a..cc40b8e651 100644 --- a/packages/flutter/test/services/deferred_component_test.dart +++ b/packages/flutter/test/services/deferred_component_test.dart @@ -15,12 +15,12 @@ void main() { log.add(methodCall); }); - await DeferredComponent.installDeferredComponent(moduleName: 'testModuleName'); + await DeferredComponent.installDeferredComponent(componentName: 'testComponentName'); expect(log, hasLength(1)); expect(log.single, isMethodCall( 'installDeferredComponent', - arguments: {'loadingUnitId': -1, 'moduleName': 'testModuleName'}, + arguments: {'loadingUnitId': -1, 'componentName': 'testComponentName'}, )); }); @@ -31,12 +31,12 @@ void main() { log.add(methodCall); }); - await DeferredComponent.uninstallDeferredComponent(moduleName: 'testModuleName'); + await DeferredComponent.uninstallDeferredComponent(componentName: 'testComponentName'); expect(log, hasLength(1)); expect(log.single, isMethodCall( 'uninstallDeferredComponent', - arguments: {'loadingUnitId': -1, 'moduleName': 'testModuleName'}, + arguments: {'loadingUnitId': -1, 'componentName': 'testComponentName'}, )); }); }