Skip to content

Platform.environment seems like a copy of env variables, created for every get of the getter #15872

@sethladd

Description

@sethladd

Not sure what the right behavior/docs are, but I found it surprising that Platform.environment returns a new Map every time I access the getter.

import 'dart:io';

void main() {
  var stuff = Platform.environment;

  print(stuff);

  stuff['foo'] = 'bar';

  print(stuff);

  var stuff2 = Platform.environment;

  print(stuff2);

  print(stuff2['foo']); // XXX this is null
}

Either Platform.environment is meant to return a singleton map (one map for the platform), or is meant to return an unmodifiable map, or is meant to always return a mutable copy.

If the last case, I recommend we update the API docs.

Thoughts?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions