Posts

Showing posts from October, 2020

Top 10 Array utility methods you should know (Dart)

As part of my venture into client-side application development with Dart , I began exploring the way one could go about working with Lists or Array types. Aside from the documentation being comprehensive, I was also able to find support on the StackOverflow community and successfully achieved what was needed. → Continue reading on my blog In today’s article we’ll be looking at the “batteries-included” notion of Dart, in particular the inbuilt utilities for working with Lists. I’ve hand-picked 10 of the most common ones you show know for your next app. I’ve also prepared the example snippets so you could play with those yourself 😁 So, shall we begin? 1. forEach() Runs a function on each element in the list var fruits = [‘banana’, ‘pineapple’, ‘watermelon’]; fruits . forEach((fruit) => print(fruit)) ; // => banana pineapple watermelon 2. map() Produces a new list after transforming each element in a given list var mappedFruits = fruits.map((fruit) => ‘I love $fruit’) .toL...