Skip to content

Instantly share code, notes, and snippets.

@Blasanka
Last active January 15, 2020 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blasanka/791f022c90b7a38822fa77acf0781682 to your computer and use it in GitHub Desktop.
Save Blasanka/791f022c90b7a38822fa77acf0781682 to your computer and use it in GitHub Desktop.
How to add values to a Map and finally that map to a list (Dart).
void main() {
List<Map> _pecasList = [];
List<String> alphas = ["a", "b", "c"];
Map<String, dynamic> newPecas = Map();
for (String c in alphas) {
if (c.isEmpty || c.trimLeft() == "") {
print("Campo Vazio");
} else {
newPecas["title$c"] = c.trimLeft();
}
}
_pecasList.add(newPecas);
print(_pecasList);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment