Problem
Running flutter test in a fresh checkout fails with 12 compilation errors:
lib/env/prod_env.dart:XX: Error: Undefined name '_ProdEnv'.
lib/env/dev_env.dart:XX: Error: Undefined name '_DevEnv'.
The envied-generated .g.dart files are gitignored (correctly — they contain obfuscated secrets). But env.dart imports dev_env.dart on line 1 to provide a default DevEnv() fallback in Env.init(). This creates a transitive dependency: any code that imports env.dart → needs dev_env.dart → needs dev_env.g.dart → needs build_runner.
Since most of the app imports env.dart, 12 of 18 test files fail to compile.
Impact
- Agent-friendliness: Any AI agent running
flutter test on a fresh checkout/worktree gets 12 false failures
- CI gap: No GitHub Actions workflow runs Flutter tests, so this has gone unnoticed
test.sh works around it by detecting missing files and running build_runner, but bare flutter test should also work
Root Cause
lib/env/env.dart line 1:
import 'package:omi/env/dev_env.dart';
Line 10:
_instance = instance ?? DevEnv() as EnvFields;
The DevEnv() default is never used — main.dart always calls Env.init(DevEnv()) or Env.init(ProdEnv()) explicitly.
Fix
Remove the dev_env.dart import from env.dart and make Env.init() require an argument (no default fallback). This breaks the transitive codegen dependency. Tests can use Env.init(TestEnvFields()) without needing build_runner.
Also update test.sh to run all 18 test files instead of only the 9 currently listed.
Problem
Running
flutter testin a fresh checkout fails with 12 compilation errors:The envied-generated
.g.dartfiles are gitignored (correctly — they contain obfuscated secrets). Butenv.dartimportsdev_env.darton line 1 to provide a defaultDevEnv()fallback inEnv.init(). This creates a transitive dependency: any code that importsenv.dart→ needsdev_env.dart→ needsdev_env.g.dart→ needs build_runner.Since most of the app imports
env.dart, 12 of 18 test files fail to compile.Impact
flutter teston a fresh checkout/worktree gets 12 false failurestest.shworks around it by detecting missing files and running build_runner, but bareflutter testshould also workRoot Cause
lib/env/env.dartline 1:Line 10:
The
DevEnv()default is never used —main.dartalways callsEnv.init(DevEnv())orEnv.init(ProdEnv())explicitly.Fix
Remove the
dev_env.dartimport fromenv.dartand makeEnv.init()require an argument (no default fallback). This breaks the transitive codegen dependency. Tests can useEnv.init(TestEnvFields())without needing build_runner.Also update
test.shto run all 18 test files instead of only the 9 currently listed.