AirHotReload class
Hot Module Reload (HMR) support for development.
This utility allows reloading individual modules during development without a full application restart, while optionally preserving their reactive state.
Example:
await AirHotReload().hotReload(
'my_module',
onBeforeReload: () async {
// Save any pending state
},
onAfterReload: () async {
// Reinitialize subscriptions
},
);
Constructors
- AirHotReload()
-
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAvailable → bool
-
Check if HMR is available (only in debug mode)
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addReloadListener(
String moduleId, VoidCallback callback) → void - Add a listener to be notified before a module is reloaded
-
clear(
) → void - Clear all preserved state (for testing)
-
hasPreservedState(
String moduleId) → bool - Check if there's preserved state for a module
-
hotReload(
String moduleId, {Future< void> onBeforeReload()?, Future<void> onAfterReload()?, List<String> ? stateKeysToPreserve}) → Future<void> - Hot reload a module while preserving its state
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
preserveState(
String moduleId, Map< String, dynamic> state) → void - Preserve state before module reload
-
removeReloadListener(
String moduleId, VoidCallback callback) → void - Remove a reload listener
-
restoreState(
String moduleId) → Map< String, dynamic> ? - Restore preserved state after module reload
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited