Skip to content

Commit

Permalink
🎨 optimize Utils.removeUndefinedFromList
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse committed Apr 10, 2024
1 parent 0d9bb6c commit 294fb6c
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,21 +369,17 @@ final class Utils {
}

@visibleForTesting
static void removeUndefinedFromList(dynamic value) {
if (value is List) {
for (int i = 0; i < value.length; i++) {
final dynamic item = value[i];
if (item is Undefined) {
value.removeAt(i);
i--;
} else if (item is Map) {
removeUndefinedFromMap(item);
} else if (item is List) {
removeUndefinedFromList(item);
}
static void removeUndefinedFromList(List value) {
for (int i = 0; i < value.length; i++) {
final dynamic item = value[i];
if (item is Undefined) {
value.removeAt(i);
i--;
} else if (item is Map) {
removeUndefinedFromMap(item);
} else if (item is List) {
removeUndefinedFromList(item);
}
} else if (value is Map) {
removeUndefinedFromMap(value);
}
}

Expand Down

0 comments on commit 294fb6c

Please sign in to comment.