WtConfig class

Global, immutable application configuration (the Flutter equivalent of wt_config.php). Initialise once in main() with WtConfig.init.

v1.1 adds the knobs a real backend needs — response envelopes, a bearer token pulled from the session, a logical success flag and request-body sanitisation control — so WtModel works against enveloped/authenticated APIs, not just bare REST endpoints.

v1.4 adds the animation defaults (animationsEnabled, pageTransition, animDuration, animCurve) used by the WT animation layer and WtRouter.

Constructors

WtConfig({required String appName, required String baseUrl, required String secretKey, ThemeData? theme, bool debugMode = false, String? envelopeKey, String messageKey = 'msg', String? successKey, String tokenKey = 'token', bool sanitizeRequests = false, bool animationsEnabled = true, WtTransition pageTransition = WtTransition.platform, Duration animDuration = const Duration(milliseconds: 300), Curve animCurve = Curves.easeOut, Duration? requestTimeout = const Duration(seconds: 30), int maxRetries = 0})
const

Properties

animationsEnabled bool
Global animation switch. When false, WT entrance animations show their final state instantly and WtRouter skips page transitions. The OS "reduce motion" setting is always honoured regardless of this flag.
final
animCurve Curve
Default curve for WT entrance animations and page transitions.
final
animDuration Duration
Default duration for WT entrance animations and page transitions.
final
appName String
App display name (MaterialApp title).
final
baseUrl String
API base URL, no trailing slash (e.g. https://example.com).
final
debugMode bool
Verbose logging when true.
final
envelopeKey String?
When set, WtModel unwraps response[envelopeKey] before parsing, so an API that replies { "state": true, "data": {...} } is read transparently. Leave null for a bare API that returns the object/array directly.
final
hashCode int
The hash code for this object.
no setterinherited
maxRetries int
How many times WtModel retries a GET that times out, fails to connect, or returns 5xx (exponential backoff). 0 = no retry (default). Non-idempotent verbs (POST/PUT/DELETE) are never auto-retried.
final
messageKey String
Key holding a human-readable error message in a failed response body (e.g. msg). Surfaced in WtModelException.message.
final
pageTransition WtTransition
Default page transition used by WtRouter when a WtRoute doesn't set its own. Defaults to WtTransition.platform so upgrading changes nothing.
final
requestTimeout Duration?
Per-request timeout for JSON calls. Null disables the timeout. Multipart uploads are exempt (they can legitimately run long).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sanitizeRequests bool
Client-side sanitisation of request bodies. Off by default: the server is the source of truth (prepared statements / server escaping) and blanket keyword stripping corrupts legitimate content.
final
secretKey String
Shared secret for WtSecurity hashing / session obfuscation.
final
successKey String?
When set, a 2xx response whose body[successKey] is falsy is still treated as a failure (for APIs that return 200 with { "state": false }).
final
theme ThemeData?
Optional Material theme.
final
tokenKey String
Session key under which the bearer token is stored; WtModel injects it as Authorization: Bearer <token> automatically when present.
final

Methods

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 WtConfig
no setter
maybeInstance WtConfig?
The active config, or null if init hasn't been called. Non-throwing — used by the animation layer so it can fall back to defaults before init runs.
no setter

Static Methods

init(WtConfig config) → void