Dart: How to Add new Key/Value Pairs to a Map
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
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
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
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
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
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
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
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
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
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
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
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…