Created
November 3, 2022 04:33
-
-
Save jamieastley/6a04adb31e50da8bfcf7ef2b136e302e to your computer and use it in GitHub Desktop.
Fold comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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