Skip to content

Commit d79b3e4

Browse files
committed
Another fix try
1 parent 6005b53 commit d79b3e4

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ dependencies:
1111

1212
dev_dependencies:
1313
dart_flutter_team_lints: ^3.5.2
14+
os_detect: ^2.0.3
1415
test: ^1.24.0

test/gzip_test.dart

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'dart:convert';
6-
import 'dart:io';
76
import 'dart:typed_data';
87

98
import 'package:gzip/gzip.dart';
@@ -36,14 +35,6 @@ void main() {
3635
}
3736
}
3837

39-
final osHeader = Platform.isLinux
40-
? 3
41-
: Platform.isMacOS
42-
? 19
43-
: Platform.isWindows
44-
? 10
45-
: -1;
46-
4738
final cases = [
4839
(
4940
name: 'Simple ASCII',
@@ -58,7 +49,7 @@ final cases = [
5849
0,
5950
0,
6051
0,
61-
osHeader,
52+
3,
6253
243,
6354
72,
6455
205,
@@ -95,7 +86,7 @@ final cases = [
9586
0,
9687
0,
9788
0,
98-
osHeader,
89+
3,
9990
1,
10091
55,
10192
0,

test/helper_web.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,20 @@
44

55
import 'dart:typed_data';
66

7-
Uint8List switchPlatformBit(List<int> input) => Uint8List.fromList(input);
7+
import 'package:os_detect/os_detect.dart';
8+
9+
Uint8List switchPlatformBit(List<int> input) {
10+
const osBit = 9;
11+
if (operatingSystemVersion.contains('linux')) {
12+
input[osBit] = 3;
13+
} else if (operatingSystemVersion.contains('macos')) {
14+
input[osBit] = 19;
15+
} else if (operatingSystemVersion.contains('windows')) {
16+
input[osBit] = 10;
17+
} else {
18+
throw UnimplementedError(
19+
'No OS bit for platform $operatingSystemVersion found',
20+
);
21+
}
22+
return Uint8List.fromList(input);
23+
}

0 commit comments

Comments
 (0)