StorageEnvironment class

Singleton class providing application-wide access to storage directories, device identifiers, application metadata, and real-time network connectivity.

This environment class centralizes essential runtime properties required by:

  • Storage systems (e.g., file caching, offline-first storage)
  • Network-aware services
  • Application-level diagnostics

Key features:

  • Provides paths to the app’s cache and temporary directories.
  • Exposes the application’s package info (e.g., app name).
  • Retrieves a stable device ID across supported platforms.
  • Offers real-time network connectivity status as both a value and a stream.

Usage:

await StorageEnvironment.instance.initialize();
final cacheDir = StorageEnvironment.instance.applicationCacheDirectory;
final deviceId = StorageEnvironment.instance.deviceId;
final isOnline = StorageEnvironment.instance.hasConnection;

Note: Call initialize once before accessing any properties to ensure proper setup.

Properties

applicationCachePath String
Absolute path to the application cache directory.
latefinal
appName String
Lowercase application name (used for consistent folder naming or IDs).
latefinal
connectionStream Stream<bool>
Emits real-time updates when network connectivity changes.
no setter
deviceId String?
Unique device identifier for the current platform.
latefinal
hasConnection bool
Indicates the current network connectivity status:
no setter
hashCode int
The hash code for this object.
no setterinherited
initialized bool
no setter
initializedStream Stream<bool>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
temporaryPath String
Absolute path to the temporary directory.
latefinal

Methods

initialize() Future<void>
Initializes the storage environment by:
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

instance StorageEnvironment
no setter