How to make Comments in Flutter & Dart
This is a concise article about commenting in Flutter and Dart. Single-Line Comment (Format Comment) Just put two slash symbols at the beginning of the line you want to comment out. // This is a......
This is a concise article about commenting in Flutter and Dart. Single-Line Comment (Format Comment) Just put two slash symbols at the beginning of the line you want to comment out. // This is a......
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: // KindaCode.com void main() { String totTitle(String......
Imagine your boss gives you a Dart map like so: final Map<String, int> myMap = { 'a': 10, 'b': 20, 'c': 15, 'd': 5, 'e': 14 }; And then, he asks you to sort the map in the ascending/descending order of the......
The two examples below show you how to reverse and shuffle a given list in Dart. Reversing a Dart list Reversing a list means changing the order of the elements in the list so that the first element becomes the last, the second......
This short example-based article shows you a few ways to find the sum of all values in a given map in Dart (presume that all the values are numbers). Using a For/In loop Example: // main.dart void main() { const......
The three examples below show you three different ways to reverse a given string in Dart (e.g. turn ABC to CBA). Turn the String into an Array Example: // KindaCode.com // main.dart // Define a reusable function String......
In Flutter and Dart, you can subtract two dates by using the DateTime.difference method. The result is a duration. Example: void main() { final DateTime dateOne = DateTime(2022, 8, 30, 16, 59, 59); final DateTime dateTwo =......
When working with Dart and Flutter, there might be cases where you want to turn a Duration into a string of HH:mm:ss format: HH: hours (If it is less than 10, there will be a preceding zero) mm: minutes as 2 digits from 00 to......
When working with Flutter and Dart, there might be cases where you have to check whether a given string is null or empty. We can define a reusable function to do the job as follows: bool validateInput(String? input) { if (input ==......
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, it will wait......
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 a list into a set and vice versa, turn a set......
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 best strategy to get the job done is to use a map to store the frequency of each element in the list......