Skip to content

Commit

Permalink
Fix null path for screenshot manager
Browse files Browse the repository at this point in the history
  • Loading branch information
narumi147 committed Oct 28, 2023
1 parent 7b98fcc commit 181a370
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/core/catcher_2_screenshot_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Catcher2ScreenshotManager {
Duration delay = const Duration(milliseconds: 20),
}) async {
try {
if (_path?.isEmpty ?? false) {
if (_path?.isEmpty ?? true) {
return null;
}
final content = await _capture(
Expand All @@ -40,15 +40,16 @@ class Catcher2ScreenshotManager {
);

if (content != null) {
return saveFile(content);
return _saveFile(content);
}
} catch (exception) {
_logger.warning('Failed to create screenshot file: $exception');
}
return null;
}

Future<File> saveFile(Uint8List fileContent) async {
Future<File> _saveFile(Uint8List fileContent) async {
assert(_path != null && _path!.isNotEmpty, '_path is empty');
final name = 'catcher_2_${DateTime.now().microsecondsSinceEpoch}.png';
final file = await File('$_path/$name').create(recursive: true);
file.writeAsBytesSync(fileContent);
Expand Down

0 comments on commit 181a370

Please sign in to comment.