Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Conversation

gspencergoog
Copy link
Contributor

This adds constants for each of the platforms so that you can write:

switch (platform.operatingSystem) {
  case Platform.macOS:
	// ...
	break;
  case Platform.linux:
	// ...
	break;
  // ...
}

Instead of having to know what the exact case-sensitive strings are that are possible values for operatingSystem, you can now use these constants in conditionals, and you can access the list of possible values from Platform.operatingSystemValues.

Sure, they're still strings, but you can treat them a little more like enum values (without the switch statement validation, sadly).

@gspencergoog
Copy link
Contributor Author

cc @tvolkert

@tvolkert
Copy link
Contributor

Man, I wish we could re-write the dart:io API surface from scratch...

@gspencergoog
Copy link
Contributor Author

@tvolkert this is ready to submit now (I fixed the formatting)

@tvolkert tvolkert merged commit f63fd0b into dart-archive:master Apr 2, 2021
mosuem pushed a commit to dart-lang/core that referenced this pull request Oct 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants