Dart

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

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

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

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

Using Cascade Notation in Dart and Flutter

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

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

Updated: August 24, 2023 By: A Goodman

In Dart, the List class has 4 methods that can help you find the index of a specific element in a list: The examples below will help you understand them better. Example 1: Finding the Index…

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

Updated: August 24, 2023 By: A Goodman

This short post shows you 2 ways to count the number of words in a given string in Dart (and Flutter as well). Using the split() method We can use the split() method to return the…

Dart: Capitalize the First Letter of Each Word in a String

Updated: March 31, 2023 By: A Goodman

The example below shows you how to capitalize the first letter of each word in a string (use a title case for each word in a string) in Dart (and Flutter as well). The code: Output:…

Dart: Convert Map to Query String and vice versa

Updated: April 23, 2023 By: A Goodman

This article shows you how to turn a given map into a query string and parse a given query string into a map in Dart (and Flutter as well) without using any third-party packages. Convert a…

Dart: Find List Elements that Satisfy Conditions

Updated: April 23, 2023 By: Guest Contributor

When developing apps with Flutter and Dart, you’ll be working a lot with lists. One of the most common tasks when working with lists is finding elements that satisfy single or multiple conditions. This article walks…

Conditional (Ternary) Operator in Dart and Flutter

Updated: April 19, 2023 By: Guest Contributor

This article is a deep dive into conditional (ternary) operators in Dart and Flutter. The Basic The conditional (ternary) operator is just a Dart operator that takes three operands: a condition followed by a question mark…

2 Ways to Create Multi-Line Strings in Dart

Updated: April 22, 2023 By: Pennywise

This concise and straightforward article shows you two different ways to create multi-line strings in Dart (and Flutter as well). Using Triple Quotes Both triple-single-quote (”’) and triple-double-quote (“””) work fine. Example: Output: Note that anything…

1 3 4 5 6 7 8