Flutter Engine
The Flutter Engine
|
#include <asset_manager.h>
Public Member Functions | |
AssetManager () | |
~AssetManager () override | |
bool | PushFront (std::unique_ptr< AssetResolver > resolver) |
Adds an asset resolver to the front of the resolver queue. Assets would be loaded from this resolver before any follwing resolvers. More... | |
bool | PushBack (std::unique_ptr< AssetResolver > resolver) |
Adds an asset resolver to the end of the resolver queue. Assets would be loaded from this resolver after any previous resolvers. More... | |
void | UpdateResolverByType (std::unique_ptr< AssetResolver > updated_asset_resolver, AssetResolver::AssetResolverType type) |
Replaces an asset resolver of the specified type with updated_asset_resolver . The matching AssetResolver is removed and replaced with updated_asset_resolvers . More... | |
std::deque< std::unique_ptr< AssetResolver > > | TakeResolvers () |
bool | IsValid () const override |
bool | IsValidAfterAssetManagerChange () const override |
Certain asset resolvers are still valid after the asset manager is replaced before a hot reload, or after a new run configuration is created during a hot restart. By preserving these resolvers and re-inserting them into the new resolver or run configuration, the tooling can avoid needing to sync all application assets through the Dart devFS upon connecting to the VM Service. Besides improving the startup performance of running a Flutter application, it also reduces the occurrence of tool failures due to repeated network flakes caused by damaged cables or hereto unknown bugs in the Dart HTTP server implementation. More... | |
AssetResolver::AssetResolverType | GetType () const override |
Gets the type of AssetResolver this is. Types are defined in AssetResolverType. More... | |
std::unique_ptr< fml::Mapping > | GetAsMapping (const std::string &asset_name) const override |
std::vector< std::unique_ptr< fml::Mapping > > | GetAsMappings (const std::string &asset_pattern, const std::optional< std::string > &subdir) const override |
Same as GetAsMapping() but returns mappings for all files who's name matches a given pattern. Returns empty vector if no matching assets are found. More... | |
bool | operator== (const AssetResolver &other) const override |
const AssetManager * | as_asset_manager () const override |
Public Member Functions inherited from flutter::AssetResolver | |
AssetResolver ()=default | |
virtual | ~AssetResolver ()=default |
virtual const AssetManager * | as_asset_manager () const |
virtual const APKAssetProvider * | as_apk_asset_provider () const |
virtual const DirectoryAssetBundle * | as_directory_asset_bundle () const |
virtual bool | IsValid () const =0 |
virtual bool | IsValidAfterAssetManagerChange () const =0 |
Certain asset resolvers are still valid after the asset manager is replaced before a hot reload, or after a new run configuration is created during a hot restart. By preserving these resolvers and re-inserting them into the new resolver or run configuration, the tooling can avoid needing to sync all application assets through the Dart devFS upon connecting to the VM Service. Besides improving the startup performance of running a Flutter application, it also reduces the occurrence of tool failures due to repeated network flakes caused by damaged cables or hereto unknown bugs in the Dart HTTP server implementation. More... | |
virtual AssetResolverType | GetType () const =0 |
Gets the type of AssetResolver this is. Types are defined in AssetResolverType. More... | |
virtual std::unique_ptr< fml::Mapping > | GetAsMapping (const std::string &asset_name) const =0 |
virtual std::vector< std::unique_ptr< fml::Mapping > > | GetAsMappings (const std::string &asset_pattern, const std::optional< std::string > &subdir) const |
Same as GetAsMapping() but returns mappings for all files who's name matches a given pattern. Returns empty vector if no matching assets are found. More... | |
virtual bool | operator== (const AssetResolver &other) const =0 |
bool | operator!= (const AssetResolver &other) const |
Additional Inherited Members | |
Public Types inherited from flutter::AssetResolver | |
enum | AssetResolverType { kAssetManager , kApkAssetProvider , kDirectoryAssetBundle } |
Identifies the type of AssetResolver an instance is. More... | |
Definition at line 19 of file asset_manager.h.
|
default |
|
overridedefault |
|
inlineoverridevirtual |
Reimplemented from flutter::AssetResolver.
Definition at line 95 of file asset_manager.h.
|
overridevirtual |
Implements flutter::AssetResolver.
Definition at line 63 of file asset_manager.cc.
|
overridevirtual |
Same as GetAsMapping() but returns mappings for all files who's name matches a given pattern. Returns empty vector if no matching assets are found.
[in] | asset_pattern | The pattern to match file names against. |
[in] | subdir | Optional subdirectory in which to search for files. If supplied this function does a flat search within the subdirectory instead of a recursive search through the entire assets directory. |
Reimplemented from flutter::AssetResolver.
Definition at line 81 of file asset_manager.cc.
|
overridevirtual |
Gets the type of AssetResolver this is. Types are defined in AssetResolverType.
Implements flutter::AssetResolver.
Definition at line 110 of file asset_manager.cc.
|
overridevirtual |
Implements flutter::AssetResolver.
Definition at line 100 of file asset_manager.cc.
|
overridevirtual |
Certain asset resolvers are still valid after the asset manager is replaced before a hot reload, or after a new run configuration is created during a hot restart. By preserving these resolvers and re-inserting them into the new resolver or run configuration, the tooling can avoid needing to sync all application assets through the Dart devFS upon connecting to the VM Service. Besides improving the startup performance of running a Flutter application, it also reduces the occurrence of tool failures due to repeated network flakes caused by damaged cables or hereto unknown bugs in the Dart HTTP server implementation.
Implements flutter::AssetResolver.
Definition at line 105 of file asset_manager.cc.
|
overridevirtual |
Implements flutter::AssetResolver.
Definition at line 114 of file asset_manager.cc.
bool flutter::AssetManager::PushBack | ( | std::unique_ptr< AssetResolver > | resolver | ) |
Adds an asset resolver to the end of the resolver queue. Assets would be loaded from this resolver after any previous resolvers.
Definition at line 25 of file asset_manager.cc.
bool flutter::AssetManager::PushFront | ( | std::unique_ptr< AssetResolver > | resolver | ) |
Adds an asset resolver to the front of the resolver queue. Assets would be loaded from this resolver before any follwing resolvers.
Definition at line 16 of file asset_manager.cc.
std::deque< std::unique_ptr< AssetResolver > > flutter::AssetManager::TakeResolvers | ( | ) |
Definition at line 58 of file asset_manager.cc.
void flutter::AssetManager::UpdateResolverByType | ( | std::unique_ptr< AssetResolver > | updated_asset_resolver, |
AssetResolver::AssetResolverType | type | ||
) |
Replaces an asset resolver of the specified type
with updated_asset_resolver
. The matching AssetResolver is removed and replaced with updated_asset_resolvers
.
AssetResolvers should be updated when the existing resolver becomes obsolete and a newer one becomes available that provides updated access to the same type of assets as the existing one. This update process is meant to be performed at runtime.
If a null resolver is provided, nothing will be done. If no matching resolver is found, the provided resolver will be added to the end of the AssetManager resolvers queue. The replacement only occurs with the first matching resolver. Any additional matching resolvers are untouched.
[in] | updated_asset_resolver | The asset resolver to replace the resolver of matching type with. |
[in] | type | The type of AssetResolver to update. Only resolvers of the specified type will be replaced by the updated resolver. |
Definition at line 34 of file asset_manager.cc.