Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
flutter::AssetResolver Class Referenceabstract

#include <asset_resolver.h>

Inheritance diagram for flutter::AssetResolver:
flutter::APKAssetProvider flutter::AssetManager flutter::DirectoryAssetBundle flutter::testing::TestAssetResolver flutter::testing::ThreadCheckingAssetResolver

Public Types

enum  AssetResolverType { kAssetManager , kApkAssetProvider , kDirectoryAssetBundle }
 Identifies the type of AssetResolver an instance is. More...
 

Public Member Functions

 AssetResolver ()=default
 
virtual ~AssetResolver ()=default
 
virtual const AssetManageras_asset_manager () const
 
virtual const APKAssetProvideras_apk_asset_provider () const
 
virtual const DirectoryAssetBundleas_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::MappingGetAsMapping (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
 

Detailed Description

Definition at line 21 of file asset_resolver.h.

Member Enumeration Documentation

◆ AssetResolverType

Identifies the type of AssetResolver an instance is.

Enumerator
kAssetManager 
kApkAssetProvider 
kDirectoryAssetBundle 

Definition at line 30 of file asset_resolver.h.

Constructor & Destructor Documentation

◆ AssetResolver()

flutter::AssetResolver::AssetResolver ( )
default

◆ ~AssetResolver()

virtual flutter::AssetResolver::~AssetResolver ( )
virtualdefault

Member Function Documentation

◆ as_apk_asset_provider()

virtual const APKAssetProvider * flutter::AssetResolver::as_apk_asset_provider ( ) const
inlinevirtual

Definition at line 37 of file asset_resolver.h.

37 {
38 return nullptr;
39 }

◆ as_asset_manager()

virtual const AssetManager * flutter::AssetResolver::as_asset_manager ( ) const
inlinevirtual

Reimplemented in flutter::AssetManager.

Definition at line 36 of file asset_resolver.h.

36{ return nullptr; }

◆ as_directory_asset_bundle()

virtual const DirectoryAssetBundle * flutter::AssetResolver::as_directory_asset_bundle ( ) const
inlinevirtual

Definition at line 40 of file asset_resolver.h.

40 {
41 return nullptr;
42 }

◆ GetAsMapping()

virtual std::unique_ptr< fml::Mapping > flutter::AssetResolver::GetAsMapping ( const std::string &  asset_name) const
pure virtual

◆ GetAsMappings()

virtual std::vector< std::unique_ptr< fml::Mapping > > flutter::AssetResolver::GetAsMappings ( const std::string &  asset_pattern,
const std::optional< std::string > &  subdir 
) const
inlinevirtual

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.

Parameters
[in]asset_patternThe pattern to match file names against.
[in]subdirOptional 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.
Returns
Returns a vector of mappings of files which match the search parameters.

Reimplemented in flutter::AssetManager, and flutter::testing::TestAssetResolver.

Definition at line 91 of file asset_resolver.h.

92 {
93 return {};
94 };

◆ GetType()

virtual AssetResolverType flutter::AssetResolver::GetType ( ) const
pure virtual

Gets the type of AssetResolver this is. Types are defined in AssetResolverType.

Returns
Returns the AssetResolverType that this resolver is.

Implemented in flutter::testing::ThreadCheckingAssetResolver, flutter::AssetManager, and flutter::testing::TestAssetResolver.

◆ IsValid()

virtual bool flutter::AssetResolver::IsValid ( ) const
pure virtual

◆ IsValidAfterAssetManagerChange()

virtual bool flutter::AssetResolver::IsValidAfterAssetManagerChange ( ) const
pure virtual

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.

Returns
Returns whether this resolver is valid after the asset manager or run configuration is updated.

Implemented in flutter::AssetManager, flutter::testing::TestAssetResolver, and flutter::testing::ThreadCheckingAssetResolver.

◆ operator!=()

bool flutter::AssetResolver::operator!= ( const AssetResolver other) const
inline

Definition at line 98 of file asset_resolver.h.

98 {
99 return !operator==(other);
100 }
virtual bool operator==(const AssetResolver &other) const =0

◆ operator==()

virtual bool flutter::AssetResolver::operator== ( const AssetResolver other) const
pure virtual

The documentation for this class was generated from the following file: