RemoteConfigMiddleware class
Middleware that injects remote configuration values into worker configs at execution time.
Use this to control worker behaviour dynamically at runtime — no app update required. Values can come from any source: Firebase Remote Config, AWS AppConfig, LaunchDarkly, or a plain REST endpoint.
Usage
// 1. Fetch values from your config source (e.g. Firebase Remote Config)
final rc = FirebaseRemoteConfig.instance;
await rc.fetchAndActivate();
// 2. Register middleware once at startup (or refresh on config change)
await NativeWorkManager.registerMiddleware(
RemoteConfigMiddleware(
values: {
'timeout': rc.getInt('download_timeout_seconds'),
'maxRetries': rc.getInt('max_retries'),
},
workerType: 'HttpDownload', // optional: only targets HttpDownloadWorker
),
);
To refresh the config (e.g. after a Remote Config fetch), simply call
registerMiddleware again with updated values — the native side
replaces the previous entry for the remoteConfig type.
How it works
Each key in values is injected directly into the native worker config map, overriding any existing value with the same name. If workerType is provided, the middleware only applies to workers whose class name contains that string (case-insensitive substring match).
- Inheritance
-
- Object
- Middleware
- RemoteConfigMiddleware
Constructors
-
RemoteConfigMiddleware({required Map<
String, dynamic> values, String? workerType}) -
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ Map<
String, dynamic> -
Config values to inject into matching worker configurations.
final
- workerType → String?
-
Optional worker class name filter (case-insensitive substring match).
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> -
Convert to map for platform channel.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited