Kinda Code
Home/Dart/Page 2

Dart

Using List.generate() in Flutter and Dart (4 examples)

Using List.generate() in Flutter and Dart (4 examples)

Updated: Sep 10, 2023
This concise, exampled-base article helps you deeply understand the List.generate() constructor in Dart (and Flutter as well). Without any further ado (such as explaining what Flutter is or rambling about its awesome features),......
Flutter: How to Fully Print a Long String/List/Map

Flutter: How to Fully Print a Long String/List/Map

Updated: Sep 01, 2023
If you’re running a Flutter with an iOS simulator or an Android emulator by using the following command: flutter run Then you’ll notice that whenever you print out a long string, list, map, or JSON data to the terminal......
Dart & Flutter: Get the Index of a Specific Element in a List

Dart & Flutter: Get the Index of a Specific Element in a List

Updated: Aug 24, 2023
In Dart, the List class has 4 methods that can help you find the index of a specific element in a list: indexOf: Returns the first index of the first element in the list that equals a given element. Returns -1 if nothing is......
Dart & Flutter: 2 Ways to Count Words in a String

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

Updated: Aug 24, 2023
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 list of the substrings between the white spaces......
Flutter & Dart: Regular Expression Examples

Flutter & Dart: Regular Expression Examples

Updated: Aug 24, 2023
A few examples of regular expression and the RegExp class in Flutter and Dart. Example 1: Email Validation The code: // kindacode.com import 'package:flutter/foundation.dart'; void main() { RegExp exp = RegExp( ......
Set Default Parameter Values for a Function in Flutter

Set Default Parameter Values for a Function in Flutter

Updated: Aug 19, 2023
This is a short guide to default parameter values for a function in Flutter (and Dart as well). Default function parameters allow formal parameters to be initialized with default values if no value is......
Dart: Converting a List to a Map and Vice Versa

Dart: Converting a List to a Map and Vice Versa

Updated: Aug 05, 2023
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 right in. Turning Lists into Maps Using List.asMap()......
Flutter & Dart: fold() method examples

Flutter & Dart: fold() method examples

Updated: Aug 05, 2023
Some common use cases of the fold() method in Dart (and Flutter as well). Calculating the Sum of a List What this example does is simply find the sum of a given numeric list: import 'package:flutter/foundation.dart'; void......
Dart & Flutter: Convert String/Number to Byte Array (Byte List)

Dart & Flutter: Convert String/Number to Byte Array (Byte List)

Updated: Jun 06, 2023
This concise article shows you how to convert a string or a number (integer or double) to a byte array (a list of bytes) in Dart (and Flutter as well). Converting a String into a Byte Array There is more than one way to turn a......
Flutter & Dart: Convert a String/Integer to Hex

Flutter & Dart: Convert a String/Integer to Hex

Updated: Jun 05, 2023
This practical shows you how to convert a number (integer) or a string to a hexadecimal value in Dart (and Flutter as well). Turn a Number into Hex Calling the toRadixString() method with a radix of 16 will produce a hex string......
Flutter & Dart: Convert Strings to Binary

Flutter & Dart: Convert Strings to Binary

Updated: Jun 05, 2023
Binary is made up of 0s and 1s, arranged in a sequence, and can be of any length. This quick article will show you how to convert a given string into binary in Dart (and Flutter as well). The steps: Declare a function named......
Flutter/Dart: Generate Random Numbers between Min and Max

Flutter/Dart: Generate Random Numbers between Min and Max

Updated: Jun 05, 2023
A couple of examples of generating a random integer within a given range in Dart (and Flutter as well). Example 1: Using Random().nextInt() method The code: // KindaCode.com import 'dart:math'; import......