How to Flatten a Nested List in Dart

October 6, 2022 A Goodman

In Dart, you can use the expand() method is to look for nested collections inside your collection and flatten them into a single list. Example: Output: Further reading: Flutter & Dart: Displaying Large Numbers with Digit…

Inheritance in Dart: A Quick Example

October 6, 2022 A Goodman

In Dart, you can use the extends keyword with any class when you want to extend the superclass’s functionality. A class can only extend one class since Dart does not support multiple inheritances. Below is a…

Flutter & Dart: 3 Ways to Generate Random Strings

October 4, 2022 A Goodman

This article shows you 3 different approaches to generating random strings in Dart (and Flutter as well). Without any further ado, let’s dive into the code. Joining Random Alphabet Letters and Numbers The example below demonstrates…

Flutter & Dart: Displaying Large Numbers with Digit Grouping

August 19, 2022 A Goodman

Displaying large numbers with commas as thousands separators will increase the readability. This short article will show you how to do so in Dart (and Flutter as well) with the help of the NumberFormat class from…

Using Static Methods in Dart and Flutter

August 19, 2022 A Goodman

In Dart and Flutter, a static method (or a static function) is a method defined as a member of a class but can be directly called without creating an object instance via the constructor. In other…

Prevent VS Code from Auto Formatting Flutter/Dart Code

August 19, 2022 A Goodman

By default, VS Code (Visual Studio Code) will automatically format your code when you save a Dart file. In general, this feature is useful and automatically makes your code cleaner, and has a consistent arrangement. However,…

Dart: Converting a List to a Map and Vice Versa

July 11, 2022 A Goodman

In this article, we will go over a couple of different ways to convert a list to a map as well as turn a map into a list in Dart. Without any further ado, let’s dive…

Dart: Checking whether a Map is empty

August 19, 2022 A Goodman

In Dart, you can check if a given map is empty or not in several ways. The most convenient approaches are to use the isEmpty, isNotEmpty, or length properties. Example: Output: We’ve traversed an example that…

Dart: Checking if a Map contains a given Key/Value

July 10, 2022 A Goodman

Dart provides us the tools to quickly and conveniently check whether a map contains a given key or value. These tools are the containsKey() method and containsValue() method. Example: Output: Further reading: Dart: How to Add…

Dart: How to Add new Key/Value Pairs to a Map

July 10, 2022 A Goodman

This concise, practical article shows you a few ways to add new key/value pairs to a given map in Dart (and Flutter as well). Using map[newKey] = newValue syntax Example: Output: Using addAll() method This method…

Dart: How to Update a Map

July 10, 2022 A Goodman

This succinct, practical article shows you 3 ways to update a map in Dart (and Flutter as well). 1 – Using map[key] = [newValue] syntax This approach is straightforward and makes the code easy to read…

Dart: How to remove specific Entries from a Map

July 10, 2022 A Goodman

In Dart, you can remove key/value pairs from a given map by using one of the following methods: remove(): Removes the entry associated with the provided key. No error will occur even if the provided key…

1 2 3 4 5 7