DEV Community

Cover image for 5 Flutter Dart Tips.
Dreamy Developer
Dreamy Developer

Posted on

5 Flutter Dart Tips.

1) .any

This is a list of Languages

.any

And you can use the .any to check whether any elements of this iterable to satisfy the test.

In this example we verify if any language starts with the letter D or B

The first one is true and the second one is false.

result

2) .padRight .padLeft

You can add characters before or after a string if you use the padLeft or padRight.

padleft

This number is the total amount of character you will have and

total

This is what will be added inside your string

string

You can do the same thing with the padRight.

3) .shuffle()

It is sometimes useful to randomize items inside the list

shuffle

For this you can use the shuffle and you can see that everything is now randomized.
ran

4) String Multiplication

It is possible to use string multiplication with dart.

This example will print x times your string.
String Multiplication

5) .toSet()

If you have a list of repeated items.

toset

You can use the .toSet() to remove all the duplicates and this is the final result.

res

Top comments (0)