Built-in Types
Every piece of Sprout's data fits into a handful of types that ship with Dart. Knowing which one to reach for, and what each one does at the edges, saves you from bugs like a watering interval of 3.5 days or a lookup that silently returns nothing.
The rule
Numbers, text, truth, and three collections: List, Set, Map.
Single values
int days = 3; // whole numbers
double litres = 0.25; // numbers with a fractional part
String name = 'Fern'; // text, single or double quotes
bool outdoors = false; // true or falseint and double are both kinds of num. Strings can embed values with interpolation: '$name needs ${litres * 1000} ml' gives Fern needs 250.0 ml. Use $name for a plain variable and ${...} for any expression.
Collections
List<String> order = ['Fern', 'Cactus', 'Fern']; // ordered, duplicates allowed
Set<String> kinds = {'Fern', 'Cactus'}; // no duplicates
Map<String, int> every = {'Fern': 3, 'Cactus': 14}; // key to value- A List keeps position:
order[0]is'Fern'. - A Set keeps each value once:
order.toSet().lengthis2. - A Map looks up by key:
every['Fern']is3, andevery['Palm']isnull, which is why its type isint?.