-
Spruce up your Dart code with generators
If you’re a programmer, regardless of your domain, you probably write a lot of code that deals with sequences of values. In most cases, a data structure like an array is the best tool for these jobs. You can simply write out every value your program will need to process as a constant before the program runs. Your program can then iterate through the data structure at runtime and pull out new values one at a time.
-
Dart's constructor syntax in action
In my last post, I showcased Dart’s efficient constructor syntax for assigning parameters to instance variables. Today I’m giving you some short example code to work with so you can see just how quickly you can build out a new class in Dart.
-
How Dart cuts away boilerplate code
When you think of the process of creating software, what image comes to mind? If you’ve never actually written a substantial program before, you’d be forgiven for assuming it to be a fairly linear series of steps. Perhaps it begins with an architect, who draws up specific plans for every aspect of the program. Then it might be up to a team of developers to convert those plans into code. The developers would probably need to communicate with one another to decide on which conventions to use, but as long as they stick to the architect’s plan, development should be pretty straightforward.
-
Dart's elegant optional arguments
Almost all modern programming languages include the concept of optional arguments. The idea is pretty easy to understand. Every function has a list of zero or more arguments (also called parameters) that serve as the function’s input values. When you call a function, you supply values for these arguments. Many arguments are required, meaning that you must supply their values in order to call the function. Optional arguments, however, can be omitted. When you don’t specify a value for an optional argument, a default value is used.
-
Dart's cascade syntax will change your life
If you’ve been working with code for a while–in any language–no doubt you’ve run into a situation like this: