Rename 'moduleName' to 'componentName' (#77789)
This commit is contained in:
parent
8b889d3551
commit
57dc5f294b
@ -6,7 +6,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'system_channels.dart';
|
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
|
/// Deferred components allow Flutter applications to download precompiled AOT
|
||||||
/// dart code and assets at runtime, reducing the install size of apps and
|
/// dart code and assets at runtime, reducing the install size of apps and
|
||||||
@ -25,12 +25,12 @@ class DeferredComponent {
|
|||||||
// prevents instantiation and extension.
|
// prevents instantiation and extension.
|
||||||
DeferredComponent._();
|
DeferredComponent._();
|
||||||
|
|
||||||
// TODO(garyq): We should eventually expand this to install modules by loadingUnitId
|
// TODO(garyq): We should eventually expand this to install components by loadingUnitId
|
||||||
// as well as moduleName, but currently, loadingUnitId is opaque to the dart code
|
// 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
|
// so this is not possible. The API has been left flexible to allow adding
|
||||||
// loadingUnitId as a parameter.
|
// 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.
|
/// be downloaded and installed.
|
||||||
///
|
///
|
||||||
/// This method returns a Future<void> that will complete when the feature is
|
/// This method returns a Future<void> that will complete when the feature is
|
||||||
@ -45,14 +45,14 @@ class DeferredComponent {
|
|||||||
/// library loading process. For example:
|
/// library loading process. For example:
|
||||||
///
|
///
|
||||||
/// ```dart
|
/// ```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
|
/// This method will not load associated dart libraries contained in the component,
|
||||||
/// feature module, though it will download the files necessary and subsequent
|
/// though it will download the files necessary and subsequent calls to `loadLibrary()`
|
||||||
/// calls to `loadLibrary()` to load will complete faster.
|
/// to load will complete faster.
|
||||||
///
|
///
|
||||||
/// Assets installed by this method may be accessed in the same way as any other
|
/// 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.
|
/// 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),
|
/// * [loadLibrary](https://api.dart.dev/dart-mirrors/LibraryDependencyMirror/loadLibrary.html),
|
||||||
/// the dart method to trigger the installation of the corresponding deferred component that
|
/// the dart method to trigger the installation of the corresponding deferred component that
|
||||||
/// contains the dart library.
|
/// contains the dart library.
|
||||||
static Future<void> installDeferredComponent({required String moduleName}) async {
|
static Future<void> installDeferredComponent({required String componentName}) async {
|
||||||
await SystemChannels.deferredComponent.invokeMethod<void>(
|
await SystemChannels.deferredComponent.invokeMethod<void>(
|
||||||
'installDeferredComponent',
|
'installDeferredComponent',
|
||||||
<String, dynamic>{ 'loadingUnitId': -1, 'moduleName': moduleName },
|
<String, dynamic>{ '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.
|
/// uninstalled.
|
||||||
///
|
///
|
||||||
/// Since uninstallation typically requires significant disk i/o, this method only
|
/// 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),
|
/// * [loadLibrary](https://api.dart.dev/dart-mirrors/LibraryDependencyMirror/loadLibrary.html),
|
||||||
/// the dart method to trigger the installation of the corresponding deferred component that
|
/// the dart method to trigger the installation of the corresponding deferred component that
|
||||||
/// contains the dart library.
|
/// contains the dart library.
|
||||||
static Future<void> uninstallDeferredComponent({required String moduleName}) async {
|
static Future<void> uninstallDeferredComponent({required String componentName}) async {
|
||||||
await SystemChannels.deferredComponent.invokeMethod<void>(
|
await SystemChannels.deferredComponent.invokeMethod<void>(
|
||||||
'uninstallDeferredComponent',
|
'uninstallDeferredComponent',
|
||||||
<String, dynamic>{ 'loadingUnitId': -1, 'moduleName': moduleName },
|
<String, dynamic>{ 'loadingUnitId': -1, 'componentName': componentName },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,17 +324,16 @@ class SystemChannels {
|
|||||||
/// [OptionalMethodChannel.invokeMethod]):
|
/// [OptionalMethodChannel.invokeMethod]):
|
||||||
///
|
///
|
||||||
/// * `installDeferredComponent`: Requests that a deferred component identified by
|
/// * `installDeferredComponent`: Requests that a deferred component identified by
|
||||||
/// the provided loadingUnitId or moduleName be downloaded and installed.
|
/// the provided loadingUnitId or componentName be downloaded and installed.
|
||||||
/// Providing a loadingUnitId with null moduleName will install a dynamic
|
/// Providing a loadingUnitId with null componentName will install a component that
|
||||||
/// feature module that includes the desired loading unit. If a moduleName
|
/// includes the desired loading unit. If a componentName is provided, then the
|
||||||
/// is provided, then the deferred component with the moduleName will be installed.
|
/// deferred component with the componentName will be installed. This method
|
||||||
/// This method returns a future that will not be completed until the
|
/// returns a future that will not be completed until the feature is fully installed
|
||||||
/// feature is fully installed and ready to use. When an error occurs, the
|
/// and ready to use. When an error occurs, the future will complete an error.
|
||||||
/// future will complete an error. Calling `loadLibrary()` on a deferred
|
/// Calling `loadLibrary()` on a deferred imported library is equivalent to calling
|
||||||
/// imported library is equivalent to calling this method with a
|
/// this method with a loadingUnitId and null componentName.
|
||||||
/// loadingUnitId and null moduleName.
|
|
||||||
/// * `uninstallDeferredComponent`: Requests that a deferred component identified by
|
/// * `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
|
/// uninstallation typically requires significant disk i/o, this method only
|
||||||
/// signals the intent to uninstall. Actual uninstallation (eg, removal of
|
/// signals the intent to uninstall. Actual uninstallation (eg, removal of
|
||||||
/// assets and files) may occur at a later time. However, once uninstallation
|
/// assets and files) may occur at a later time. However, once uninstallation
|
||||||
|
@ -15,12 +15,12 @@ void main() {
|
|||||||
log.add(methodCall);
|
log.add(methodCall);
|
||||||
});
|
});
|
||||||
|
|
||||||
await DeferredComponent.installDeferredComponent(moduleName: 'testModuleName');
|
await DeferredComponent.installDeferredComponent(componentName: 'testComponentName');
|
||||||
|
|
||||||
expect(log, hasLength(1));
|
expect(log, hasLength(1));
|
||||||
expect(log.single, isMethodCall(
|
expect(log.single, isMethodCall(
|
||||||
'installDeferredComponent',
|
'installDeferredComponent',
|
||||||
arguments: <String, dynamic>{'loadingUnitId': -1, 'moduleName': 'testModuleName'},
|
arguments: <String, dynamic>{'loadingUnitId': -1, 'componentName': 'testComponentName'},
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -31,12 +31,12 @@ void main() {
|
|||||||
log.add(methodCall);
|
log.add(methodCall);
|
||||||
});
|
});
|
||||||
|
|
||||||
await DeferredComponent.uninstallDeferredComponent(moduleName: 'testModuleName');
|
await DeferredComponent.uninstallDeferredComponent(componentName: 'testComponentName');
|
||||||
|
|
||||||
expect(log, hasLength(1));
|
expect(log, hasLength(1));
|
||||||
expect(log.single, isMethodCall(
|
expect(log.single, isMethodCall(
|
||||||
'uninstallDeferredComponent',
|
'uninstallDeferredComponent',
|
||||||
arguments: <String, dynamic>{'loadingUnitId': -1, 'moduleName': 'testModuleName'},
|
arguments: <String, dynamic>{'loadingUnitId': -1, 'componentName': 'testComponentName'},
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user