Replace custom Platform & PlatformChecker with package platform
Description
Replace:
- dart/lib/src/platform/platform.dart
- dart/lib/src/platform_checker.dart
with https://pub.dev/packages/platform
Update: we've done some improvements/refactors in PlatformChecker but this issue is blocked until dart officially adds support for web as well, see https://github.com/dart-lang/core/pull/862
@vaind Hey! Just started this and i'm seeing that example_web_compile_test.dart fails, as a file in the package uses dart:io
https://github.com/dart-lang/core/blob/main/pkgs/platform/lib/src/interface/local_platform.dart
Not sure how to circumvent this. Any suggestions?
You should be checking for "kIsWeb" (or do the same check in Dart code) before using the platform package.
You should be checking for "kIsWeb" (or do the same check in Dart code) before using the platform package.
we can definitely work around this but then we'd still have to use the existing impl for web so not sure if it's worth it to use it? wdyt
Any suggestions?
Is there a branch I can have a look at?
@vaind Pushed the code i had locally. Pretty much replaced our Platform definition in favour of package:platform/platform.dart, but here we have the issue that dart:io is used.
I've missed that package:platform doesn't support web at the moment. I've opened a draft PR to add support but for now, we cannot use it.
At the very least, I've taken a stab at cleaning up PlatformChecker (moving actual platform-specific stuff to the Platform) and added TODOs for potential improvements. @denrase see https://github.com/getsentry/sentry-dart/pull/2730 what do you think about these changes and the TODOs in PlatformChecker. Also, feel free to pick it up as I won't have the capacity to do so in the next couple of days, other than fixing any CI issues with #2730
@vaind Thank you for your insights and the PR, i'll take a look at it. 🙇