|
1 | | -import 'dart:ffi' as ffi; |
2 | 1 | import 'dart:io'; |
3 | 2 |
|
| 3 | +import 'package:pslab/console_helper_dummy.dart' |
| 4 | + if (dart.library.io) 'package:pslab/console_helper.dart' as console_helper; |
| 5 | + |
4 | 6 | import 'package:pslab/providers/sht21_provider.dart'; |
5 | 7 | import 'package:flutter/foundation.dart'; |
6 | 8 | import 'package:flutter/material.dart'; |
@@ -42,7 +44,7 @@ void main(List<String> args) async { |
42 | 44 | (Platform.isWindows || Platform.isLinux || Platform.isMacOS) && |
43 | 45 | args.any((a) => a == '-v' || a == '--version')) { |
44 | 46 | if (Platform.isWindows) { |
45 | | - _attachParentConsole(); |
| 47 | + console_helper.attachParentConsole(); |
46 | 48 | } |
47 | 49 | final info = await PackageInfo.fromPlatform(); |
48 | 50 | stdout.writeln('${info.appName} ${info.version}+${info.buildNumber}'); |
@@ -175,14 +177,6 @@ class _LocaleAware extends StatelessWidget { |
175 | 177 | } |
176 | 178 | } |
177 | 179 |
|
178 | | -void _attachParentConsole() { |
179 | | - const attachParentProcess = 0xFFFFFFFF; |
180 | | - final kernel32 = ffi.DynamicLibrary.open('kernel32.dll'); |
181 | | - final attachConsole = kernel32.lookupFunction<ffi.Int32 Function(ffi.Uint32), |
182 | | - int Function(int)>('AttachConsole'); |
183 | | - attachConsole(attachParentProcess); |
184 | | -} |
185 | | - |
186 | 180 | void _preCacheImages(BuildContext context) { |
187 | 181 | for (final path in instrumentIcons) { |
188 | 182 | precacheImage(AssetImage(path), context); |
|
0 commit comments