Answers for "Dart set list collection operator"

0

Dart set list collection operator

/*Dart also offers collection if and collection for, which you can use to build 
collections using conditionals (if) and repetition (for).
Here’s an example of using collection if to create a list with three or four items 
in it:*/

var nav = [
  'Home',
  'Furniture',
  'Plants',
  if (promoActive) 'Outlet'
];
/*Here’s an example of using collection for to manipulate the items of a list
before adding them to another list:*/

var listOfInts = [1, 2, 3];
var listOfStrings = [
  '#0',
  for (var i in listOfInts) '#$i'
];
assert(listOfStrings[1] == '#1');
Posted by: Guest on August-16-2021

Code answers related to "Dart"

Browse Popular Code Answers by Language