Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OS constants for use in switch statements #30

Merged
merged 3 commits into from
Apr 2, 2021

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-lang:master Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants