mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-30 17:52:33 +01:00
The Android-only options (the Android system actions in the button editor, the phone-steering switch, local control through the accessibility service) are gated on dart:io's Platform, which in a test is always the desktop host. The feature video needs to film them. Those gates now read HostPlatform, which is dart:io's Platform unless a test sets the test-only debugHostPlatformOverride. It is null everywhere else, so nothing changes outside tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
30 lines
1.2 KiB
Dart
30 lines
1.2 KiB
Dart
import 'dart:io' show Platform;
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
/// Stands another operating system in for the one the app runs on, for the
|
|
/// gates that go through [HostPlatform]. For the feature-video capture, which
|
|
/// films the Android build's options on a desktop test host. Off everywhere
|
|
/// else: while null, [HostPlatform] is dart:io's [Platform].
|
|
@visibleForTesting
|
|
TargetPlatform? debugHostPlatformOverride;
|
|
|
|
/// The operating system BikeControl runs on, as the feature gates that read it
|
|
/// see it — dart:io's [Platform] (false on the web), unless a test stages
|
|
/// another one with [debugHostPlatformOverride].
|
|
abstract final class HostPlatform {
|
|
static bool get isAndroid => _is(TargetPlatform.android, () => Platform.isAndroid);
|
|
|
|
static bool get isIOS => _is(TargetPlatform.iOS, () => Platform.isIOS);
|
|
|
|
static bool get isMacOS => _is(TargetPlatform.macOS, () => Platform.isMacOS);
|
|
|
|
static bool get isWindows => _is(TargetPlatform.windows, () => Platform.isWindows);
|
|
|
|
static bool _is(TargetPlatform platform, bool Function() host) {
|
|
final override = debugHostPlatformOverride;
|
|
if (override != null) return override == platform;
|
|
return !kIsWeb && host();
|
|
}
|
|
}
|