Closed penkzhou closed 3 weeks ago
cc @navaronbracke .
@penkzhou Just to be sure, this is primarily for people that write tests, right?
I had a look at the implementation of defaultTargetPlatform
and that uses the Platform.is
getters under the hood on non-web platforms.
@penkzhou Just to be sure, this is primarily for people that write tests, right?
I had a look at the implementation of
defaultTargetPlatform
and that uses thePlatform.is
getters under the hood on non-web platforms.
IMO, it is the best practise. According to the official doc, The [dart:io.Platform](https://api.flutter.dev/flutter/dart-io/Platform-class.html) object should only be used directly when it's critical to actually know the current platform, without any overrides possible (for example, when a system API is about to be called).
You are correct, yes. In these cases, we already called the native side and we just parse the result. There is no "system level API" that we needed to call here.
yeah. with defaultTargetPlatform, we can change the platform in test case with debugDefaultTargetPlatformOverride
api. the ref is here.
@navaronbracke I just add the additional change on the example/lib/barcode_scanner_window.dart
,Could you please help review this?
If you want to update the version to
5.0.1
and update the changelog to include a mention of this fix, that would be helpful.
ok.
If you want to update the version to
5.0.1
and update the changelog to include a mention of this fix, that would be helpful.
I have already submitted all files related to the version changes. Please take a look and let me know if any other changes are needed.
current code in
lib/src/method_channel/mobile_scanner_method_channel.dart
cannot change the platform in the test code when need to change the platform. according to this thread, maybe we should change the platform os detect pattern intodefaultTargetPlatform
. ref:https://stackoverflow.com/questions/55233853/flutter-widget-tests-with-platform-branching