Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/src/core/io/io_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'io_web.dart' if (dart.library.io) 'dart:io';
64 changes: 64 additions & 0 deletions lib/src/core/io/io_web.dart
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 {
Copy link
Owner

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?

Copy link
Author

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 a NOTICES file (similar to LICENSE) and add the license from the universal_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 a NOTICES file.

We could also do both, or just put it in the file header, whatever you prefer.

Copy link
Owner

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!

Copy link
Author

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.

/// 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')) {
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 '';
}
}
3 changes: 2 additions & 1 deletion lib/src/emoji_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import 'package:emoji_picker_flutter/locales/default_emoji_set_locale.dart';
import 'package:emoji_picker_flutter/src/emoji_picker_internal_utils.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:universal_io/io.dart';

import 'core/io/io_helper.dart';

/// All the possible categories that [Emoji] can be put into
///
Expand Down
3 changes: 2 additions & 1 deletion lib/src/emoji_picker_internal_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:universal_io/io.dart';

import 'core/io/io_helper.dart';

/// Initial value for RecentEmoji
const initVal = 1;
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
plugin_platform_interface: ^2.1.8
shared_preferences: ^2.3.3
web: ^1.1.0
universal_io: ^2.2.2

dev_dependencies:
flutter_test:
Expand Down