Issue
I have an issue in my Dart Programme. Here is a list of emojis:
[[🐃, 💧, 💦], [], [🌵, 🎄, 🌲], [], [], []] //List
Inside the list there are multiple lists (as you can see). I want to remove empty lists []
. Also I want to Join [🐃, 💧, 💦, 🌵, 🎄, 🌲] into a single list.
Solution
Full Solution:
var data = [['🐃', '💧', '💦'], [], ['🌵', '🎄', '🌲'], [], [], []];
void main() {
var newData = data.expand((x) => x).toList();
print(newData);
}
Here, newData
is your final answer as: [🐃, 💧, 💦, 🌵, 🎄, 🌲]
.
Answered By – Yatinj Sutariya
Answer Checked By – Mary Flores (FlutterFixes Volunteer)