PlugFox / platform_info

Compare b5afcf0 ... +10 ... 8c7f3b6

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 2 of 7 files from the diff.

@@ -13,6 +13,49 @@
Loading
13 13
  debug
14 14
}
15 15
16 +
/// Build mode extension
17 +
extension BuildModeX on BuildMode {
18 +
  /// Is release build mode
19 +
  bool get isRelease => this == BuildMode.release;
20 +
21 +
  /// Is profile build mode
22 +
  bool get isProfile => this == BuildMode.profile;
23 +
24 +
  /// Is debug build mode
25 +
  bool get isDebug => this == BuildMode.debug;
26 +
27 +
  /// Run callback on specific build mode
28 +
  BuildModeResult when<BuildModeResult extends Object?>({
29 +
    required BuildModeResult Function() release,
30 +
    required BuildModeResult Function() profile,
31 +
    required BuildModeResult Function() debug,
32 +
  }) {
33 +
    switch (this) {
34 +
      case BuildMode.profile:
35 +
        return profile();
36 +
      case BuildMode.debug:
37 +
        return debug();
38 +
      case BuildMode.release:
39 +
      default:
40 +
        return release();
41 +
    }
42 +
  }
43 +
44 +
  /// Run callback on specific build mode,
45 +
  /// if not specified run orElse
46 +
  BuildModeResult maybeWhen<BuildModeResult extends Object?>({
47 +
    required BuildModeResult Function() orElse,
48 +
    BuildModeResult Function()? release,
49 +
    BuildModeResult Function()? profile,
50 +
    BuildModeResult Function()? debug,
51 +
  }) =>
52 +
      when<BuildModeResult>(
53 +
        debug: debug ?? orElse,
54 +
        profile: profile ?? orElse,
55 +
        release: release ?? orElse,
56 +
      );
57 +
}
58 +
16 59
/// Host platform type
17 60
///  + io (vm, desktops, mobile, console)
18 61
///  + web (html, js, browser)
@@ -24,6 +67,22 @@
Loading
24 67
  web,
25 68
}
26 69
70 +
/// Host platform extension
71 +
extension HostPlatformTypeX on HostPlatformType {
72 +
  /// Is I/O (vm, desktops, mobile, console)
73 +
  bool get isIO => this == HostPlatformType.io;
74 +
75 +
  /// Is Web (html, js, browser)
76 +
  bool get isWeb => this == HostPlatformType.web;
77 +
78 +
  /// Run callback on specific host platform
79 +
  HostPlatformTypeResult when<HostPlatformTypeResult extends Object?>({
80 +
    required HostPlatformTypeResult Function() io,
81 +
    required HostPlatformTypeResult Function() web,
82 +
  }) =>
83 +
      this == HostPlatformType.web ? web() : io();
84 +
}
85 +
27 86
/// Operation system
28 87
///  + Fuchsia
29 88
///  + Linux
@@ -54,3 +113,77 @@
Loading
54 113
  /// Fuchsia
55 114
  fuchsia,
56 115
}
116 +
117 +
/// Operation system extension
118 +
extension OperatingSystemX on OperatingSystem {
119 +
  /// Android
120 +
  bool get isAndroid => this == OperatingSystem.android;
121 +
122 +
  /// Fuchsia
123 +
  bool get isFuchsia => this == OperatingSystem.fuchsia;
124 +
125 +
  /// iOS
126 +
  bool get isIOS => this == OperatingSystem.iOS;
127 +
128 +
  /// Linux
129 +
  bool get isLinux => this == OperatingSystem.linux;
130 +
131 +
  /// MacOS
132 +
  bool get isMacOS => this == OperatingSystem.macOS;
133 +
134 +
  /// Windows
135 +
  bool get isWindows => this == OperatingSystem.windows;
136 +
137 +
  /// Unknown
138 +
  bool get isUnknown => this == OperatingSystem.unknown;
139 +
140 +
  /// Run callback on specific operation system
141 +
  OperatingSystemResult when<OperatingSystemResult extends Object?>({
142 +
    required OperatingSystemResult Function() android,
143 +
    required OperatingSystemResult Function() fuchsia,
144 +
    required OperatingSystemResult Function() iOS,
145 +
    required OperatingSystemResult Function() linux,
146 +
    required OperatingSystemResult Function() macOS,
147 +
    required OperatingSystemResult Function() windows,
148 +
    required OperatingSystemResult Function() unknown,
149 +
  }) {
150 +
    switch (this) {
151 +
      case OperatingSystem.windows:
152 +
        return windows();
153 +
      case OperatingSystem.linux:
154 +
        return linux();
155 +
      case OperatingSystem.macOS:
156 +
        return macOS();
157 +
      case OperatingSystem.iOS:
158 +
        return iOS();
159 +
      case OperatingSystem.android:
160 +
        return android();
161 +
      case OperatingSystem.fuchsia:
162 +
        return fuchsia();
163 +
      case OperatingSystem.unknown:
164 +
      default:
165 +
        return unknown();
166 +
    }
167 +
  }
168 +
169 +
  /// Run callback on specific operation system,
170 +
  /// if not specified run orElse
171 +
  OperatingSystemResult maybeWhen<OperatingSystemResult extends Object?>({
172 +
    required OperatingSystemResult Function() orElse,
173 +
    OperatingSystemResult Function()? android,
174 +
    OperatingSystemResult Function()? fuchsia,
175 +
    OperatingSystemResult Function()? iOS,
176 +
    OperatingSystemResult Function()? linux,
177 +
    OperatingSystemResult Function()? macOS,
178 +
    OperatingSystemResult Function()? windows,
179 +
  }) =>
180 +
      when<OperatingSystemResult>(
181 +
        android: android ?? orElse,
182 +
        fuchsia: fuchsia ?? orElse,
183 +
        iOS: iOS ?? orElse,
184 +
        linux: linux ?? orElse,
185 +
        macOS: macOS ?? orElse,
186 +
        windows: windows ?? orElse,
187 +
        unknown: orElse,
188 +
      );
189 +
}

@@ -145,7 +145,7 @@
Loading
145 145
  Platform._internal({
146 146
    required this.buildMode,
147 147
    required HostPlatform hostPlatform,
148 -
  })   : _hostPlatform = hostPlatform,
148 +
  })  : _hostPlatform = hostPlatform,
149 149
        isOperatingSystemKnown =
150 150
            hostPlatform.operatingSystem != OperatingSystem.unknown,
151 151
        isMobile = kListOSForMobile.contains(hostPlatform.operatingSystem),

Learn more Showing 2 files with coverage changes found.

Changes in lib/src/methods.dart
+17
Loading file...
Changes in lib/src/platform.dart
+2
Loading file...
Files Coverage
lib 100.00%
Project Totals (7 files) 100.00%
Loading