ENGINEERING CASE STUDY

Sleep O'Clock — OLED Optical Engineering & Circadian Health

Sleep O'Clock (com.jhh.solutions.sleep_oclock, v1.8) is a bedside clock and preschooler Sleep Trainer engineered in Flutter at JHH Solutions. It solves a concrete optical and biological paradox: how can a child clearly read the clock state from 4 meters away (across a dark bedroom) without turning the smartphone display into a bright flashlight that suppresses melatonin and burns in OLED subpixels overnight?

72 Layered Dart Files
126+ Tests 23 Suites (100% Pass Rate)
11 Themes Custom Vectors (80% Scale)
-75% to -85% Nighttime APL Light Reduction

APL Optical Engineering & Active OLED Hardware Protection

Unlike conventional night clocks that merely dim a gray backdrop (leaving millions of subpixels lit), Sleep O'Clock was engineered around OLED/AMOLED display physics and APL (Average Picture Level) control:

  • True 0 nits Subpixel Shutoff: Deep-night backgrounds enforce pure #000000 black without diffuse blur halos (MaskFilter.blur), physically powering off non-active subpixels and eliminating ambient bedroom haze.
  • 80% Protagonist Vector Scale & Constellation Mode: All 11 custom CustomPainter vector themes (7 playful themes + 4 Catholic children's themes) scale to shorter * 0.80 for effortless 4-meter legibility, supporting low-emission stroke rendering (PaintingStyle.stroke) that cuts surface luminous flux by 75%–85%.
  • Active Pixel-Shifting Anti-Burn-in (AnimatedAlign): Every minute, visual coordinates smoothly recalculate within a bounded ±18% envelope, evenly distributing organic diode wear across portrait and landscape orientations with zero layout overflow.
  • Circadian Red Mode (Double-Tap): Instantly suppresses blue and green wavelengths, shifting into a deep red spectrum that preserves nocturnal melatonin synthesis.

Clean Architecture, Feature Isolation & Multi-Agent Governance

Stage 01

Gestures & Ticks

Double-Tap, 5%-100% Drag, Timer

Stage 02

ClockBloc

Immutable States

Stage 03

Pure UseCases

CheckWakeUpCondition & Routine

Stage 04

Functional Contracts

Dartz Either<Failure, T>

Stage 05

Feature-Scoped DI

clock_injection_container

Stage 06

Vector Rendering & Active Wakelock

  • Feature-Scoped Dependency Injection: The clock domain manages its own isolated get_it container (clock_injection_container.dart), decoupling core infrastructure and enabling deterministic unit/widget testing.
  • Overflow-Hardened UI & Parental Gate: ParentalGateDialog (protecting PRO settings/unlocks) and the tabbed SettingsModal are hardened against layout overflow under virtual keyboards and 1.15x accessibility text scaling.
  • Automated Quality Ritual: Delivered across 8 documented epics, gated by zero-warning static analysis (flutter analyze), 126+ unit/widget tests, and automated release-on-main.yml GitHub Actions pipelines.