DataManager class

Orchestrates the data flow for the SDK.

Constructors

DataManager(String debugLabel, {required CodelesslyConfig config, required CacheManager cacheManager, required AuthManager authManager, required NetworkDataRepository networkDataRepository, required LocalDataRepository localDataRepository, required FirebaseFirestore firebaseFirestore, required CodelesslyErrorHandler errorHandler, SDKPublishModel? publishModel})
Creates a new instance of with the given config.

Properties

authManager AuthManager
The auth manager to use. By default, it is CodelesslyAuthManager.
final
cacheManager CacheManager
The cache manager to use. By default, it is CodelesslyCacheManager which uses Hive.
final
cloudDatabase CloudDatabase?
The cloud storage instance used by this data manager. If it is null, it means it has not yet been initialized.
no setter
config CodelesslyConfig
The passed config from the SDK.
final
debugLabel String
A unique identifier of this data manager instance.
final
errorHandler → CodelesslyErrorHandler
The error handler to use.
final
firebaseFirestore → FirebaseFirestore
The firestore instance to use.
final
hashCode int
The hash code for this object.
no setterinherited
localDatabase LocalDatabase
The local storage instance used by this data manager.
no setter
localDataRepository LocalDataRepository
The local data repository to use. By default, it is going to be LocalDataRepository which uses cacheManager to abstract away data manager specific caching.
final
logLabel String
no setter
networkDataRepository NetworkDataRepository
The network data repository to use. By default, it is going to be FirebaseDataRepository.
final
publishModel SDKPublishModel?
The current publish model loaded by this data manager.
no setter
publishModelStream Stream<SDKPublishModel?>
The stream of the current publish model loaded by this data manager.
no setter
queuingDone bool
This is set to true once the while loop that processes the _downloadQueue finishes processing in the initialization of this DataManager.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status CStatus
Determines whether the data manager has been initialized at least once.
getter/setter pair

Methods

dispose() → void
Disposes the instance.
downloadFontBytesAndSave(SDKPublishFont font) Future<Uint8List?>
Downloads the bytes of a font and saves them to cache.
emitPublishModel() Future<void>
Emits the current _publishModel to the _publishModelStreamController.
fetchCompletePublishBundle({required String slug, required PublishSource source}) Future<bool>
getOrFetchApis({required Set<String> apiIds}) Set<Future<HttpApiData?>>
Gets all SDKPublishFont models of a given set of fontIDs either from local cache or downloads them from the network.
getOrFetchConditions(String layoutID) Future<SDKLayoutConditions?>
fetches conditions for a given layoutID.
getOrFetchFontBytesAndSave(SDKPublishFont font) Future<Uint8List?>
Given a font, will fetch its bytes either from cache or download & save them.
getOrFetchFontBytesAndSaveAndLoad(SDKPublishFont font) Future<void>
Wrapper for getOrFetchFontBytesAndSave that additionally loads the font into the Flutter engine.
getOrFetchFontModels({required Set<String> fontIDs}) Future<Set<SDKPublishFont>>
Gets all SDKPublishFont models of a given set of fontIDs either from local cache or downloads them from the network.
getOrFetchPopulatedLayout({required String layoutID}) Future<bool>
Downloads or looks up the requested layoutID along with its associated fonts, and emits the updated _publishModel.
getOrFetchVariables(String layoutID) Future<SDKLayoutVariables?>
fetches conditions for a given layoutID.
init({required String? layoutID}) Future<void>
Initializes the instance.
initializeCloudStorage({required String projectId}) Future<CloudDatabase>
initializeLocalStorage({required String projectId}) Future<LocalDatabase>
listenToPublishModel(String projectId) Future<SDKPublishModel>
Listen the publish model document. It's either going to be fetched for the first time if it doesn't exist in cache, or it's going to be updated with new data.
loadFont(SDKPublishFont font, Uint8List fontBytes) Future<void>
Loads a font with its associated fontBytes into the Flutter engine.
loadFontsFromPublishModel() → void
Will consume all of the SDKFontModels loaded in the _publishModel and either load them into the Flutter SDK or download them then load them.
log(String message, {bool largePrint = false}) → void
logError(String message, {required Object? error, required StackTrace? stackTrace}) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onPublishModelLoaded(String projectId) Future<bool>
Called when the publish model is loaded.
processDownloadQueue() Future<void>
processPublishDifference({required SDKPublishModel serverModel, required SDKPublishModel localModel}) Future<void>
Takes a serverModel, and localModel and compares them to determine what changed on the server. The changes are then processed and downloaded if necessary.
queueLayout({required String layoutID, bool prioritize = false}) Future<void>
Similar to getOrFetchPopulatedLayout, but utilizes the download queue to respect the order of downloads.
reset() → void
Sets the SDKPublishModel as null and cancels document streaming.
saveFontBytes(SDKPublishFont font, Uint8List fontBytes) → void
Saves the provided fontBytes with the SDKPublishFont.id from font as the storage key.
savePublishModel() → void
Saves the current _publishModel if it is not null to the local cache using localDataRepository.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited