The most efficient Dart tips

The most used dart tips to make programming easier

To make coding simpler, this post aims to describe the most popular Dart and Flutter tips. Therefore, I'd like to provide some advice that I use while creating apps with Dart or Flutter.
Check if element are iterable using Any()
Check any elements are iterable within the list:
List<String> brands = ['Adidas', 'Nike', 'Puma', 'Hummel']
brands.any((brand) => brand.startsWith('p')) // true;
brands.any((brand) => brand.startsWith('m')) // false;
Remove repetitive items from the list using ToSet()
If you have a list with repetitive items in it you can use toSet to remove all duplicated items:
List<int> list = [1, 3, 7, -6, 1, 7, 9]
list.toSet().toList();
The final result will be: [1, 3, 7, -6, 9]
Shuffle items in the list
If you want randomize items in the list use shuffle() function:
List<int> list = [1, 3, 4, 7, 9];
list.shuffle();
The result will be: [4, 7, 9, 3, 1]
Dart allows you String multiplication
You can multiply string in the Dart language:
print('$$$' * 5);
The result will be: $$$ $$$ $$$ $$$ $$$
Add characters with PadLeft and PadRight
You can add characters before any string or after it:
String text = 'Hello';
print(text.padLeft(5, '$'))
The result will print: $$$$$Hello
You can use padRight to add after string