[device_info_plus] add toMap#618
Conversation
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:async'; | ||
| import 'dart:io'; |
There was a problem hiding this comment.
Not anymore. There is still a problem with some cached compiler info, you cannot mix web and non-web builds (technically speaking runs, not builds) on a single cache. For example if you do:
$ flutter run --device-id macosthen
$ flutter run --device-id chromefails with a bunch of errors referring not only to dart:io, but hundreds of errors for dart:ffi and package:win32 which are transient dependencies from device_info_plus_windows. This is a result of merging #598. To mitigate it you have to flutter clean every time you switch running web vs. non-web platforms. When you do flutter build web this is not a problem, because it uses correct compiler every time it's invoked and does not depend on cached stuff.
| } | ||
| } | ||
|
|
||
| throw UnsupportedError('Unsupported platform'); |
There was a problem hiding this comment.
The error message probably should tell the user which the current platform is. We could also tell the user to create an issue or PR in this repo for unsupported platforms.
Also, does this need tests?
There was a problem hiding this comment.
I'm not sure about the idea of more detailed explanation. Most UnsupportedError exceptions in flutter/plugins or this repo simply states that current platform is well not supported, without any further explanation. Thats contrasting with assertion messages throughout Flutter, which are very verbose, suggesting fixes, or further actions.
|
I've added tests for new methods, missing test case for One thing to note on integration tests for web. There are two devices - $ flutter drive --driver=test_driver/device_info_plus_e2e_test.dart --target=./test_driver/device_info_plus_e2e.dart --device-id web-server
Running "flutter pub get" in example... 713ms
Launching ./test_driver/device_info_plus_e2e.dart on Web Server in debug mode...
Waiting for connection from debug service on Web Server... 20.2s
./test_driver/device_info_plus_e2e.dart is being served at http://localhost:51498
The web-server device requires the Dart Debug Chrome extension for debugging. Consider using the Chrome or Edge devices for an improved development workflow.
Application finished.That is misleading because in fact these tests were not even executed. If you run the same with $ flutter drive --driver=test_driver/device_info_plus_e2e_test.dart --target=./test_driver/device_info_plus_e2e.dart --device-id chrome
Running "flutter pub get" in example... 778ms
Launching ./test_driver/device_info_plus_e2e.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome... 17.8s
This app is linked to the debug service: ws://127.0.0.1:53361/eZTcAD6QRiA=/ws
Debug service listening on ws://127.0.0.1:53361/eZTcAD6QRiA=/ws
Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
00:00 +0: (setUpAll)
00:00 +0: (setUpAll) [E]
Unsupported operation: Platform._operatingSystem
// Long stack trace...
00:00 +0 -1: (tearDownAll)
00:00 +1 -1: Some tests failed.
Application finished.The same error can be seen at some point when running $ chromedriver --port=4444 --log-level=INFO
[1637571135.923][INFO]: [961691ef1023330da68da0c1606e647d] RESPONSE GetLog [ {
"level": "WARNING",
"message": "http://localhost:51357/dart_sdk.js 52372:16 \"registerExtension() from dart:developer is only supported in build/run/test environments where the developer event method hooks have been set.\"",
"source": "console-api",
"timestamp": 1.637571133822e+12
}, {
"level": "WARNING",
"message": "http://localhost:51357/dart_sdk.js 52351:16 \"postEvent() from dart:developer is only supported in build/run/test environments where the developer event method hooks have been set.\"",
"source": "console-api",
"timestamp": 1.637571134916e+12
}, {
"level": "INFO",
"message": "http://localhost:51357/dart_sdk.js 29445:14 \"00:00 +0: (setUpAll)\"",
"source": "console-api",
"timestamp": 1.637571134916e+12
}, {
"level": "INFO",
"message": "http://localhost:51357/dart_sdk.js 29445:14 \"00:00 +0: (setUpAll) [E]\"",
"source": "console-api",
"timestamp": 1.637571134916e+12
}, {
"level": "INFO",
"message": "http://localhost:51357/dart_sdk.js 29445:14 \" Unsupported operation: Platform._operatingSystem\"",
"source": "console-api",
"timestamp": 1.637571134917e+12
}, {
"level": "INFO",
"message": "http://localhost:51357/dart_sdk.js 29445:14 \" dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 251:49 throw_\\n dart-sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart ...",
"source": "console-api",
"timestamp": 1.63757113504e+12
}, {
"level": "INFO",
"message": "http://localhost:51357/dart_sdk.js 29445:14 \"Consider enabling the flag chain-stack-traces to receive more detailed exceptions.\\nFor example, 'dart test --chain-stack-traces'.\"",
"source": "console-api",
"timestamp": 1.63757113504e+12
}, {
"level": "INFO",
"message": "http://localhost:51357/dart_sdk.js 29445:14 \"00:00 +0 -1: (tearDownAll)\"",
"source": "console-api",
"timestamp": 1.637571135041e+12
}, {
"level": "INFO",
"message": "http://localhost:51357/dart_sdk.js 29445:14 \"00:00 +1 -1: Some tests failed.\"",
"source": "console-api",
"timestamp": 1.637571135116e+12
} ]That's because integration test itself used |
miquelbeltran
left a comment
There was a problem hiding this comment.
I like the idea! not having a common class was something that always annoyed me a bit when using this plugin.
The PR should include also the change in the Changelog and increasing the version number by a minor version (since it is not a breaking change) Could you add that before we merge?
Description
This PR adds a new superclass of platform-specific device info objects.
BaseDeviceInfoexposes one generictoMapmethod to be provided by platform-specific subclasses. Missing implementations provided for Linux and Windows. A new convenience accessordeviceInforeturns platform-specific device info. It can either be narrow-typed usingisor serialized to map.Related Issues
#615
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]).This will ensure a smooth and quick review process. Updating the
pubspec.yamland changelogs is not required.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?