-
Notifications
You must be signed in to change notification settings - Fork 150
refactor(io): replace universal_io with internal lightweight solution #237
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
Open
hm21
wants to merge
3
commits into
Fintasys:master
Choose a base branch
from
hm21:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'io_web.dart' if (dart.library.io) 'dart:io'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:web/web.dart' as web; | ||
|
||
/// Information about the environment in which the current program is running. | ||
/// | ||
/// Platform provides information such as the operating system, | ||
/// the hostname of the computer, the value of environment variables, | ||
/// the path to the running program, | ||
/// and other global properties of the program being run. | ||
class Platform { | ||
/// Whether the operating system is a version of | ||
/// [Linux](https://en.wikipedia.org/wiki/Linux). | ||
/// | ||
/// This value is `false` if the operating system is a specialized | ||
/// version of Linux that identifies itself by a different name, | ||
/// for example Android (see [isAndroid]). | ||
static final bool isLinux = (operatingSystem == 'linux'); | ||
|
||
/// Whether the operating system is a version of | ||
/// [macOS](https://en.wikipedia.org/wiki/MacOS). | ||
static final bool isMacOS = (operatingSystem == 'macos'); | ||
|
||
/// Whether the operating system is a version of | ||
/// [Microsoft Windows](https://en.wikipedia.org/wiki/Microsoft_Windows). | ||
static final bool isWindows = (operatingSystem == 'windows'); | ||
|
||
/// Whether the operating system is a version of | ||
/// [Android](https://en.wikipedia.org/wiki/Android_%28operating_system%29). | ||
static final bool isAndroid = (operatingSystem == 'android'); | ||
|
||
/// Whether the operating system is a version of | ||
/// [iOS](https://en.wikipedia.org/wiki/IOS). | ||
static final bool isIOS = (operatingSystem == 'ios'); | ||
|
||
/// Whether the operating system is a version of | ||
/// [Fuchsia](https://en.wikipedia.org/wiki/Google_Fuchsia). | ||
static final bool isFuchsia = (operatingSystem == 'fuchsia'); | ||
|
||
/// A string representing the operating system or platform. | ||
static String get operatingSystem { | ||
final s = web.window.navigator.userAgent.toLowerCase(); | ||
if (s.contains('iphone') || | ||
s.contains('ipad') || | ||
s.contains('ipod') || | ||
s.contains('watch os')) { | ||
hm21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return 'ios'; | ||
} | ||
if (s.contains('mac os')) { | ||
return 'macos'; | ||
} | ||
if (s.contains('fuchsia')) { | ||
return 'fuchsia'; | ||
} | ||
if (s.contains('android')) { | ||
return 'android'; | ||
} | ||
if (s.contains('linux') || s.contains('cros') || s.contains('chromebook')) { | ||
return 'linux'; | ||
} | ||
if (s.contains('windows')) { | ||
return 'windows'; | ||
} | ||
return ''; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it copied from somewhere? Can you add a reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fintasys Yes, you’re right, it’s a super-minified version from
universal_io
. I can add the reference directly in that file if you want, but wouldn’t it be better to create aNOTICES
file (similar toLICENSE
) and add the license from theuniversal_io
package there?That way, the license is also included when a user opens the Flutter prebuilt license page, for example via showAboutDialog. Technically, you can also add it using the
LicenseRegistry.addLicense
method, but personally, I prefer to create aNOTICES
file.We could also do both, or just put it in the file header, whatever you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you are more familiar with this than me. I would say link in the file and entry in notice should be good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I’ve added the original license header to the file and created the NOTICE file as requested.