simc / dartx

Superpowers for Dart. Collection of useful static extension methods.
https://pub.dev/packages/dartx
Apache License 2.0
1.08k stars 88 forks source link

Flatten should work with deeply nested lists as well #134

Open rishabhdeepsingh opened 3 years ago

rishabhdeepsingh commented 3 years ago

This can be achieved by setting a flag in the flatten extension or directly flattening the list. Need some more discussion.

  final nestedList = [
    [
      1,
      [2, 3]
    ],
    [4, 5, 6]
  ];
  final flattened = nestedList.flatten(); // [1, 2, 3, 4, 5, 6]