text
stringlengths 1
372
|
|---|
play-store-based implementation that the validator checks for.
|
the validator detects any new, changed, or removed
|
loading units generated by gen_snapshot.
|
the current generated loading units are tracked in your
|
<projectdirectory>/deferred_components_loading_units.yaml file.
|
this file should be checked into source control to ensure that
|
changes to the loading units by other developers can be caught.
|
the validator also checks for the following in the
|
android directory:
|
<projectdir>/android/app/src/main/res/values/strings.xml
|
an entry for every deferred component mapping the key
|
${componentname}name to ${componentname}.
|
this string resource is used by the AndroidManifest.xml
|
of each feature module to define the dist:title property.
|
for example:
|
<projectdir>/android/<componentname>
|
an android dynamic feature module for
|
each deferred component exists and contains a build.gradle
|
and src/main/AndroidManifest.xml file.
|
this only checks for existence and does not validate
|
the contents of these files. if a file does not exist,
|
it generates a default recommended one.
|
<projectdir>/android/app/src/main/res/values/androidmanifest.xml
|
contains a meta-data entry that encodes
|
the mapping between loading units and component name the
|
loading unit is associated with. this mapping is used by the
|
embedder to convert dart’s internal loading unit id
|
to the name of a deferred component to install. for example:
|
the gen_snapshot validator won’t run until the prebuild
|
validator passes.
|
for each of these checks,
|
the tool produces the modified or new files
|
needed to pass the check.
|
these files are placed in the
|
<projectdir>/build/android_deferred_components_setup_files directory.
|
it is recommended that the changes be applied by
|
copying and overwriting the same files in the
|
project’s android directory. before overwriting,
|
the current project state should be committed to
|
source control and the recommended changes should be
|
reviewed to be appropriate. the tool won’t make any
|
changes to your android/ directory automatically.
|
once the available
|
loading units are generated and logged in
|
<projectdirectory>/deferred_components_loading_units.yaml,
|
it is possible to fully configure the pubspec’s
|
deferred-components section so that the loading units
|
are assigned to deferred components as desired.
|
to continue with the box example, the generated
|
deferred_components_loading_units.yaml file would contain:
|
the loading unit id (‘2’ in this case) is used
|
internally by dart, and can be ignored.
|
the base loading unit (id ‘1’) is not listed
|
and contains everything not explicitly contained
|
in another loading unit.
|
you can now add the following to pubspec.yaml:
|
to assign a loading unit to a deferred component,
|
add any dart lib in the loading unit into the
|
libraries section of the feature module.
|
keep the following guidelines in mind:
|
loading units should not be included
|
in more than one component.
|
including one dart library from a
|
loading unit indicates that the entire loading
|
unit is assigned to the deferred component.
|
all loading units not assigned to
|
a deferred component are included in the base component,
|
which always exists implicitly.
|
loading units assigned to the same
|
deferred component are downloaded, installed,
|
and shipped together.
|
the base component is implicit and
|
need not be defined in the pubspec.
|
assets can also be included by adding
|
an assets section in the deferred component configuration:
|
an asset can be included in multiple deferred components,
|
but installing both components results in a replicated asset.
|
assets-only components can also be defined by omitting the
|
libraries section. these assets-only components must be
|
installed with the DeferredComponent utility class in
|
services rather than loadLibrary().
|
since dart libs are packaged together with assets,
|
if a dart library is loaded with loadLibrary(),
|
any assets in the component are loaded as well.
|
however, installing by component name and the services utility
|
won’t load any dart libraries in the component.
|
you are free to include assets in any component,
|
as long as they are installed and loaded when they
|
are first referenced, though typically,
|
assets and the dart code that uses those assets
|
are best packed in the same component.
|
manually add all deferred components
|
that you defined in pubspec.yaml into the
|
android/settings.gradle file as includes.
|
for example, if there are three deferred components
|
defined in the pubspec named, boxComponent, circleComponent,
|
and assetComponent, ensure that android/settings.gradle
|
contains the following:
|
repeat steps 3.1 through 3.6 (this step)
|
until all validator recommendations are handled and the tool
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.