Skip to content

feat(config): make EnvironmentConfig runtime-overridable#1435

Merged
SERDUN merged 7 commits into
developfrom
feat/environment-config-runtime-overrides
Jun 23, 2026
Merged

feat(config): make EnvironmentConfig runtime-overridable#1435
SERDUN merged 7 commits into
developfrom
feat/environment-config-runtime-overrides

Conversation

@SERDUN

@SERDUN SERDUN commented Jun 23, 2026

Copy link
Copy Markdown
Member

Overview

Convert EnvironmentConfig's compile-time *.fromEnvironment constants into getters that resolve runtime override ?? compile-time default, and add applyOverrides / clearOverrides / hasOverride. This lets an embedder (the theme configurator's realtime preview) inject the whole dart-define set at runtime. The *__NAME key constants stay const.

Nullable bool.hasEnvironment(X) ? String.fromEnvironment(X) : null fallbacks move to static const _*_ENV fields, since bool.hasEnvironment can only be used in a const context.

Because members become getters (not compile-time constants), const-context usages are adjusted (const -> final / drop const): main_shell.dart polling Durations, feature_access.dart CallTriggerConfig, logzio_logging_service.dart, autoprovision, push_tokens, several screen-page titles, and the screenshots subpackage (router + integration test + main_screen_screenshot).

Why

Independent enabler for the realtime-preview epic. On its own it changes nothing observable — standalone builds never call applyOverrides, so every value resolves to the same compile-time default as before.

Notes

  • Standalone behaviour byte-identical (overrides empty).
  • flutter analyze lib and the screenshots subpackage both green.

Convert EnvironmentConfig's compile-time *.fromEnvironment constants into
getters that resolve `runtime override ?? compile-time default`, and add
applyOverrides/clearOverrides/hasOverride. This lets an embedder (e.g. the theme
configurator's realtime preview) inject the whole dart-define set at runtime.
Standalone builds are byte-identical - no overrides are ever applied. The
*__NAME key constants stay const.

Nullable `bool.hasEnvironment(X) ? String.fromEnvironment(X) : null` fallbacks
move to `static const _*_ENV` fields, since hasEnvironment can only be used in a
const context.

Members become getters, so const-context usages are adjusted (const -> final /
drop const): main_shell.dart polling Durations, feature_access.dart
CallTriggerConfig, logzio_logging_service.dart, autoprovision, push_tokens,
several screen-page titles, and the screenshots subpackage (router + test +
main_screen_screenshot).
@SERDUN SERDUN force-pushed the feat/environment-config-runtime-overrides branch from 2fdd5b3 to 9e857d2 Compare June 23, 2026 16:17
SERDUN added 6 commits June 23, 2026 19:27
Route every EnvironmentConfig getter through a single EnvRegistry instance that
owns the override store and the typed override-first resolution
(string/stringOrNull/boolean/integer). Getters now only declare a key + a
compile-time default and ask the registry for the value - they no longer touch
the override map or know whether a value came from a runtime override or the
compile-time dart-define. applyOverrides/clearOverrides/hasOverride delegate to
the registry. No behaviour change.
Polling intervals are runtime-overridable getters fed into Duration(seconds:).
A 0 or negative override produced a zero-delay periodic poller (request storm)
or a negative-Duration assertion. Resolve every *_POLLING_INTERVAL_SECONDS
getter through _pollingSeconds(), which falls back to the compile-time default
when the override is non-positive.
REMOTE_LOGZIO_LOG_LEVEL is runtime-overridable; an override that is not an exact
Level name made Level.LEVELS.firstWhere throw StateError and crash logging setup.
Add an orElse that warns and falls back to Level.INFO.
EnvRegistry.string/stringOrNull returned an empty-string override verbatim, so
an embedder passing WEBTRIT_APP_NAME='' produced blank titles and
WEBTRIT_APP_DEMO_CORE_URL='' made Uri.parse('') the fallback core URL. A blank
dart-define means "not set", so empty overrides now fall back to the
compile-time default.
EnvRegistry.boolean/integer silently coerced malformed overrides ('yes' -> false,
'abc' -> default), so an operator's toggle could be ignored with no diagnostic.
Honour 'true'/'false' and numeric values, treat empty as unset, and log a
warning before falling back for anything else.
Add unit tests for the runtime-override mechanism that previously shipped
untested: EnvRegistry string/stringOrNull/boolean/integer (override-wins,
empty-as-unset, malformed-fallback), has/clear, and EnvironmentConfig
applyOverrides/clearOverrides incl. the non-positive polling-interval guard.
@SERDUN SERDUN marked this pull request as ready for review June 23, 2026 16:58
@SERDUN SERDUN merged commit eb55858 into develop Jun 23, 2026
2 checks passed
@SERDUN SERDUN deleted the feat/environment-config-runtime-overrides branch June 23, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant