Skip to content

Commit 0dddfe5

Browse files
authored
Merge pull request #3061 from leancodepl/feature/is-platform-getter
Add `isAndroid`, `isIOS`, `isWeb` and `isMacOS` getters
2 parents 9ec3e4f + 385bb70 commit 0dddfe5

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

packages/patrol_finders/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Unreleased
2+
3+
- Add `isAndroid`, `isIOS`, `isWeb` and `isMacOS` getters.
4+
15
## 3.3.0
26

37
- Bump `patrol_log` to `^0.9.0`.

packages/patrol_finders/lib/src/custom_finders/patrol_tester.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,21 @@ class PatrolTester {
141141
/// Flutter's widget tester that this [PatrolTester] wraps.
142142
final WidgetTester tester;
143143

144+
/// Whether the test is running on Android.
145+
bool get isAndroid => _is(TargetPlatform.android);
146+
147+
/// Whether the test is running on iOS.
148+
bool get isIOS => _is(TargetPlatform.iOS);
149+
150+
/// Whether the test is running on web.
151+
bool get isWeb => kIsWeb;
152+
153+
/// Whether the test is running on macOS.
154+
bool get isMacOS => _is(TargetPlatform.macOS);
155+
156+
bool _is(TargetPlatform platform) =>
157+
!kIsWeb && defaultTargetPlatform == platform;
158+
144159
/// Wraps a function with a log entry for the start and end of the function.
145160
Future<T> wrapWithPatrolLog<T>({
146161
required String action,

0 commit comments

Comments
 (0)