-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-refactoringIssues with analysis server refactoringsIssues with analysis server refactoringstype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
input code:
@override
Future<List<String>?> getSavedLutFolders() async {
final SharedPreferences sharedPreferences = await _sharedPreferences;
final List<String>? bookmarks =
sharedPreferences.getStringList(_sharedPreferencesKey);
if (bookmarks == null) {
return null;
}
List<String> result = [];
for (var bookmark in bookmarks) {
try {
final path = await _bookmarkToPath(bookmark);
result.add(path);
} catch (e) {
log("Error while resolving MacOS sandbox bookmark: $e");
await _rmBadBookmark(bookmark, bookmarks, sharedPreferences);
}
}
return result;
}
Future<void> _rmBadBookmark(
String bookmarkToRemove,
List<String> bookmarks,
SharedPreferences sharedPreferences,
) async {
bookmarks.remove(bookmarkToRemove);
await sharedPreferences.setStringList(_sharedPreferencesKey, bookmarks);
}inline _rmBadBookmark
result code:
@override
Future<List<String>?> getSavedLutFolders() async {
final SharedPreferences sharedPreferences = await _sharedPreferences;
final List<String>? bookmarks =
sharedPreferences.getStringList(_sharedPreferencesKey);
if (bookmarks == null) {
return null;
}
List<String> result = [];
for (var bookmark in bookmarks) {
try {
final path = await _bookmarkToPath(bookmark);
result.add(path);
} catch (e) {
log("Error while resolving MacOS sandbox bookmark: $e");
await (
String bookmarkToRemove,
List<String> bookmarks,
SharedPreferences sharedPreferences,
) async {
bookmarks.remove(bookmarkToRemove);
await sharedPreferences.setStringList(_sharedPreferencesKey, bookmarks);
}(bookmark, bookmarks, sharedPreferences);
}
}
return result;
}expected code:
@override
Future<List<String>?> getSavedLutFolders() async {
final SharedPreferences sharedPreferences = await _sharedPreferences;
final List<String>? bookmarks =
sharedPreferences.getStringList(_sharedPreferencesKey);
if (bookmarks == null) {
return null;
}
List<String> result = [];
for (var bookmark in bookmarks) {
try {
final path = await _bookmarkToPath(bookmark);
result.add(path);
} catch (e) {
log("Error while resolving MacOS sandbox bookmark: $e");
bookmarks.remove(bookmark);
await sharedPreferences.setStringList(_sharedPreferencesKey, bookmarks);
}
}
return result;
}Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-refactoringIssues with analysis server refactoringsIssues with analysis server refactoringstype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug