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

fix(device_info_plus)!: fixed webasm compliance #3254

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@
<link rel="manifest" href="manifest.json">
</head>
<body>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('flutter_service_worker.js');
});
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:js_interop';
import 'package:web/web.dart' as html show window, Navigator;

import 'package:device_info_plus_platform_interface/device_info_plus_platform_interface.dart';
Expand Down Expand Up @@ -30,7 +31,7 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
'appVersion': _navigator.appVersion,
'deviceMemory': _navigator.deviceMemory,
'language': _navigator.language,
'languages': _navigator.languages,
'languages': _navigator.languages.toDart,
arnaudruffin marked this conversation as resolved.
Show resolved Hide resolved
'platform': _navigator.platform,
'product': _navigator.product,
'productSub': _navigator.productSub,
Expand All @@ -44,10 +45,3 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
);
}
}

/// Property is missing.
/// Ticket: https://github.com/dart-lang/web/issues/192
/// Probably won't be an int? in the future!
extension on html.Navigator {
external int? get deviceMemory;
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class WebBrowserInfo implements BaseDeviceInfo {
final String? appVersion;

/// the amount of device memory in gigabytes. This value is an approximation given by rounding to the nearest power of 2 and dividing that number by 1024.
final int? deviceMemory;
final double? deviceMemory;

/// a DOMString representing the preferred language of the user, usually the language of the browser UI. The null value is returned when this is unknown.
final String? language;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {
'appCodeName': 'appCodeName',
'appName': 'appName',
'appVersion': 'appVersion',
'deviceMemory': 42,
'deviceMemory': 42.0,
'language': 'language',
'languages': ['en', 'es'],
'platform': 'platform',
Expand Down
Loading