Using Static Methods in Dart and Flutter

October 1, 2021 A Goodman

In Dart and Flutter, a static method (or 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 words,…

Prevent VS Code from Auto Formatting Flutter/Dart Code

August 24, 2021 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 makes your code cleaner, and has a consistent arrangement. However, there…

Dart: Converting a List to a Map and Vice Versa

August 19, 2021 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 map in Dart. Without any further ado, let’s dive…

Dart: Checking whether a Map is empty

August 17, 2021 A Goodman

In Dart, you can check if a given map is empty in several ways. The most convenient approaches are to using the isEmpty, isNotEmpty, or length properties. Example: Output: Further reading: Dart: Checking if a Map…

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

August 17, 2021 A Goodman

Dart provides us the tools to quickly 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 new Key/Value…

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

August 17, 2021 A Goodman

This short 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 can…

Dart: How to Update a Map

August 17, 2021 A Goodman

This short 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 and…

Dart: How to remove specific Entries from a Map

August 17, 2021 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 that associated with the provided key. No error will occur even if the provided…

Using Cascade Notation in Dart and Flutter

August 12, 2021 Guest Contributor

This short post walks you through a few examples of using the cascade notation (.., ?…) in Dart. What Is The Point? In Dart, cascades let you execute a sequence of operations on the same object….

Dart: Convert Timestamp to DateTime and vice versa

July 29, 2021 A Goodman

The examples below show you how to convert timestamp (also known as Unix time or Epoch time) to DateTime and vice versa in Dart (and Flutter as well). We can archive our goal without using any…

Dart & Flutter: Get the Index of a Specific Element in a List

July 27, 2021 A Goodman

In Dart, the List class has 4 methods that can help you find the index of a specific element in a list: indexOf: Returns the first index of the first element in the list that equals…

Dart & Flutter: 2 Ways to Count Words in a String

July 22, 2021 A Goodman

This short post shows you 2 ways to count the number of words in a given string. 1. Using split() method We can use the split() method to return the list of the substrings between the…

1 2 3 5