A real app reads Platform.environment. For a deterministic teaching example, treat env vars as a fixed Map<String, String> and decode them with ?? defaults plus simple comparisons. The pattern transfers directly to real environment maps.

Program

Play the program to parse a port and a debug flag from a fixed env map.

env_map_lite.dart
void main() {
  var env = {'APP_PORT': '8080', 'APP_DEBUG': 'true'};
  var port = int.parse(env['APP_PORT'] ?? '80');
  var debug = env['APP_DEBUG'] == 'true';
  var mode = debug ? 'debug' : 'release';
  print('$port $mode');
}
env map Treating env vars as a `Map<String, String>` keeps the example deterministic without `Platform.environment`.
safe parse `env['APP_PORT'] ?? '80'` falls back to a default before `int.parse` runs.
string flag Booleans usually arrive as strings; comparing `== 'true'` decodes them safely.