2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
+ import 'package:meta/meta.dart' ;
5
6
import 'package:vm_service/vm_service.dart' as vm_service;
6
7
7
8
import '../base/common.dart' ;
@@ -168,7 +169,7 @@ class ScreenshotCommand extends FlutterCommand {
168
169
sink.add (base64.decode (skp.json? ['skp' ] as String ));
169
170
await sink.close ();
170
171
_showOutputFileInfo (outputFile);
171
- _ensureOutputIsNotJsonRpcError (outputFile);
172
+ ensureOutputIsNotJsonRpcError (outputFile);
172
173
return true ;
173
174
}
174
175
@@ -192,7 +193,7 @@ class ScreenshotCommand extends FlutterCommand {
192
193
sink.add (base64.decode (response.json? ['screenshot' ] as String ));
193
194
await sink.close ();
194
195
_showOutputFileInfo (outputFile);
195
- _ensureOutputIsNotJsonRpcError (outputFile);
196
+ ensureOutputIsNotJsonRpcError (outputFile);
196
197
return true ;
197
198
}
198
199
@@ -205,15 +206,16 @@ class ScreenshotCommand extends FlutterCommand {
205
206
}
206
207
}
207
208
208
- void _ensureOutputIsNotJsonRpcError (File outputFile) {
209
+ @visibleForTesting
210
+ static void ensureOutputIsNotJsonRpcError (File outputFile) {
209
211
if (outputFile.lengthSync () >= 1000 ) {
210
212
return ;
211
213
}
212
214
final String content = outputFile.readAsStringSync (
213
215
encoding: const AsciiCodec (allowInvalid: true ),
214
216
);
215
217
if (content.startsWith ('{"jsonrpc":"2.0", "error"' )) {
216
- throwToolExit ('It appears the output file contains an error message, not valid skia output.' );
218
+ throwToolExit ('It appears the output file contains an error message, not valid output.' );
217
219
}
218
220
}
219
221
0 commit comments