Skip to content

Commit

Permalink
fix: replace elementAtOrNull with try-catch to fix method not found e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
tdiam committed Oct 22, 2023
1 parent c207269 commit e5c2a63
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/src/features/home/data/appimage_tools_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,22 @@ class AppimageToolsRepository {
FileSystemEntity file,
) async {
// Delete Icons
String? iconName = (await Process.run(
"grep",
[
"^Icon=",
_localPathService.applicationsDir + content[index] + ".desktop",
],
runInShell: true,
workingDirectory: _localPathService.applicationsDir,
))
.stdout
.split("=")
.elementAtOrNull(1)
?.trim();
String? iconName;
try {
iconName = (await Process.run(
"grep",
[
"^Icon=",
_localPathService.applicationsDir + content[index] + ".desktop",
],
runInShell: true,
workingDirectory: _localPathService.applicationsDir,
))
.stdout
.split("=")[1]
.trim();
} on RangeError {}

for (var icon
in Directory(_localPathService.iconsDir).listSync(recursive: true)) {
if (p.basenameWithoutExtension(icon.path) == iconName) {
Expand Down

0 comments on commit e5c2a63

Please sign in to comment.