Dart

Dart: Extract a substring from a given string (advanced)

Updated: March 31, 2023 By: Pennywise

This article is about extracting a substring from a given string in Dart (and Flutter as well). We’ll cover the fundamentals, write a simple program, then walks through a few advanced use cases. Without any further…

Dart: Check whether a string starts/ends with a substring

Updated: March 31, 2023 By: A Goodman

To check if a string starts with or ends with a given substring in Dart (and Flutter as well), you can use the startsWith() method and the endsWith() method, respectively: These methods are case-sensitive (distinguish between…

Dart: Convert Class Instances (Objects) to Maps and Vice Versa

Updated: January 13, 2023 By: A Goodman

This article walks you through a few examples of converting a class instance (object) into a map and vice versa in Dart (and Flutter as well). Learning through examples is the best way to deepen understanding…

How to Flatten a Nested List in Dart

Updated: October 6, 2022 By: 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

Updated: October 6, 2022 By: 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

Updated: October 4, 2022 By: 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

Updated: August 19, 2022 By: 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

Updated: August 19, 2022 By: 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

Updated: August 19, 2022 By: 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

Updated: August 5, 2023 By: 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

Updated: August 19, 2022 By: 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

Updated: July 10, 2022 By: 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…

1 2 3 4 5 6 8