Flutter & Dart: How to Check if a String is Null/Empty

May 11, 2022 The Plumber

When working with Flutter and Dart, there might be cases where you have to check whether a given string is null or empty. Suppose that our app’s functionality only continues when the string is neither null…

Dart: Using Async and Await in Loops

April 20, 2022 Pennywise

In Dart (and Flutter as well), you can perform synchronous operations sequentially in loops by using Future.forEach. The example program below will print the numbers from 1 to 10. Every time it finishes printing a number,…

Dart: Converting a List to a Set and vice versa

March 20, 2022 Pennywise

In Dart, a list is an indexable collection of objects with a length while a set is a collection of objects where each object can occur only once. This short article shows you how to convert…

Flutter & Dart: Count Occurrences of each Element in a List

March 16, 2022 Pennywise

When working with Dart and Flutter, there might be cases where you want to count the occurrences of each element in a given list. The simple example below will demonstrate how to do that: Output: That’s…

Flutter & Dart: Convert a String into a List and vice versa

March 7, 2022 Pennywise

In Flutter and Dart, you can turn a given string into a list (with string elements) by using the split() method. Example: Output: To convert a list of strings to a string, you can use the…

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

March 7, 2022 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

March 7, 2022 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

January 7, 2022 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). Converting a Dart Object to a Map At the time…

How to Flatten a Nested List in Dart

December 3, 2021 Pennywise

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

December 3, 2021 Pennywise

In Dart, you can use the extends keyword with any class where 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

November 24, 2021 Guest Contributor

This article shows you 3 different approaches to generate a random string 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…

Flutter & Dart: Displaying Large Numbers with Digit Grouping

November 7, 2021 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…

1 2 3 5