Skip to content

Instantly share code, notes, and snippets.

@jamieastley
Created November 3, 2022 04:33
Show Gist options
  • Select an option

  • Save jamieastley/6a04adb31e50da8bfcf7ef2b136e302e to your computer and use it in GitHub Desktop.

Select an option

Save jamieastley/6a04adb31e50da8bfcf7ef2b136e302e to your computer and use it in GitHub Desktop.
Fold comparison
void main() {
final items = [['one', 'two', 'three'], ['one', 'two']];
final currentImpl = [
...{for (var list in items) ...list ?? []}
];
print(currentImpl);
final folded = items.fold<List<String>>( <String>[], (previousLineItems, lineItem) => previousLineItems..addAll(lineItem!));
print(folded);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment