critical priority medium complexity frontend pending frontend specialist Tier 3

Acceptance Criteria

A DesignTokenProvider class exists in lib/design_system/ with static const or final members for all color, typography, spacing, and sizing tokens.
The class is sealed or annotated to prevent subclassing — token values are not overridable at runtime.
Color tokens are typed as Color (not dynamic or int) and named following a semantic convention (e.g., colorPrimary500, colorSurfaceDefault, colorErrorDefault).
Typography tokens are exposed as a Flutter TextTheme instance (or named TextStyle constants) matching the type scale names defined in the Accessibility Token Manifest.
Spacing tokens are typed as double constants following an 8dp grid (e.g., spacingXs = 4.0, spacingS = 8.0, spacingSM = 12.0, spacingM = 16.0, spacingL = 24.0, spacingXL = 32.0, spacingXXL = 48.0).
Sizing tokens are typed as double or Size constants and match the min_touch_target values declared in the manifest (e.g., minTouchTarget = 48.0).
A companion test file verifies that every symbolic token name referenced in the Accessibility Token Manifest has a corresponding constant in DesignTokenProvider — no manifest entry is unresolved.
All four organisation themes (NHF, Blindeforbundet, HLF, Barnekreftforeningen) are supported via a theme variant parameter or separate themed token sets, not by duplicating the entire provider.
The DesignTokenProvider can be instantiated (or accessed statically) without any Flutter widget tree context — it is a pure Dart object.
dartdoc comments on every public member reference the corresponding Accessibility Token Manifest entry and WCAG criterion where applicable.

Technical Requirements

frameworks
Flutter
Dart
Riverpod
data models
AccessibilityTokenManifest
ColorPairEntry
TypeScaleConstraint
SizingConstraint
performance requirements
All token access is O(1) — no runtime lookup tables
DesignTokenProvider initialization must be synchronous and complete before the first frame
security requirements
Token values must be compile-time constants where possible to prevent runtime mutation
ui components
Flutter TextTheme
ColorScheme (Material 3)

Execution Context

Execution Tier
Tier 3

Tier 3 - 413 tasks

Can start after Tier 2 completes

Implementation Notes

Structure DesignTokenProvider with three inner classes: DesignTokenProvider.colors (static Color constants), DesignTokenProvider.typography (static TextStyle / TextTheme), and DesignTokenProvider.layout (spacing + sizing). This mirrors Flutter's Theme breakdown and makes autocomplete easier for downstream developers. For multi-org theming, use a factory constructor or a static method (DesignTokenProvider.forOrganisation(OrgTheme theme)) that returns an instance configured for the given org — do not use Flutter's ThemeExtension unless the team already uses it, as it adds complexity. Keep primitive colors (e.g., Color(0xFF1A73E8)) in a private _ColorPrimitives inner class and expose only semantic aliases (colorPrimary500 = _ColorPrimitives.blue600) in the public API — this two-layer approach is industry standard (Figma tokens, Tailwind, etc.) and prevents accidental use of primitives.

Generate the TextTheme using Google Fonts or the project's font package if applicable, but ensure it is compatible with system font scaling (textScaler) for accessibility.

Testing Requirements

Write unit tests (no widget tree required) covering: (1) All color token values match expected hex values for each organisation theme — use a lookup map and iterate; (2) All spacing token values follow the 8dp grid (value % 4 == 0 for all spacing constants); (3) minTouchTarget is exactly 48.0; (4) TextTheme font sizes match the min_font_size_sp values in the manifest; (5) The manifest-completeness test: load the manifest, extract all symbolic token names, and assert each resolves to a non-null constant in DesignTokenProvider. Additionally write a widget test that creates a MaterialApp using DesignTokenProvider.themeData and asserts Theme.of(context).colorScheme.primary equals the expected primary color for a given organisation.

Component
Design Token Provider
data medium
Epic Risks (3)
high impact medium prob technical

The WCAG 2.2 relative luminance formula requires gamma-corrected sRGB calculations. Floating-point rounding differences between Dart and reference implementations could produce off-by-one classifications for near-threshold color pairs, resulting in pairs that just pass or just fail in CI but behave differently at runtime.

Mitigation & Contingency

Mitigation: Implement the algorithm directly from the WCAG 2.2 specification using the exact linearisation constants. Validate the Dart implementation against the W3C reference test vectors and against a known-good JavaScript implementation for at least 50 color pairs spanning the compliance boundaries.

Contingency: If discrepancies are found, add a configurable tolerance margin (e.g., ±0.005 on the ratio) and flag near-threshold pairs as warnings rather than hard failures, escalating to the design team for manual review.

medium impact high prob scope

The token manifest is a static data file. If developers add new color tokens to the design-token-provider without updating the manifest, the manifest becomes stale and the CI validator produces false negatives — passing builds that contain unvalidated color pairs.

Mitigation & Contingency

Mitigation: Add a CI step that cross-references every token constant exported by the design-token-provider against the manifest at build time, failing if any token is present in the provider but absent from the manifest. Document this requirement clearly in the contributing guide.

Contingency: If drift is detected post-merge, run a full manifest regeneration script and treat the resulting manifest diff as a blocking pull request with mandatory accessibility review.

medium impact medium prob dependency

The flutter_accessibility_lints package (or custom lint rules) may produce false positives on patterns the team deliberately uses — for example, decorative icon widgets that intentionally omit semantic labels. Excessive false positives will lead developers to add blanket ignore comments, undermining the entire lint strategy.

Mitigation & Contingency

Mitigation: Audit the full lint rule set against the existing codebase before enabling rules. Create a documented list of approved ignore-comment patterns with mandatory justification comments. Restrict ignore patterns to decorative-only contexts.

Contingency: If false positive rates exceed 10% of lint output, disable the highest-noise individual rules and replace them with targeted custom lint rules scoped to the specific patterns the team controls.