Flutter Engine
flutter::AssetResolver Class Referenceabstract

#include <asset_resolver.h>

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

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 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...
 

Detailed Description

Definition at line 17 of file asset_resolver.h.

Member Enumeration Documentation

◆ AssetResolverType

Identifies the type of AssetResolver an instance is.

Enumerator
kAssetManager 
kApkAssetProvider 
kDirectoryAssetBundle 

Definition at line 26 of file asset_resolver.h.

Constructor & Destructor Documentation

◆ AssetResolver()

flutter::AssetResolver::AssetResolver ( )
default

◆ ~AssetResolver()

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

Member Function Documentation

◆ 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::testing::TestAssetResolver, and flutter::AssetManager.

Definition at line 79 of file asset_resolver.h.

80  {
81  return {};
82  };

◆ 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::TestAssetResolver, and flutter::AssetManager.

◆ 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::testing::TestAssetResolver, and flutter::AssetManager.


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