I'm iOS Developer and new for Flutter. In the Swift language If we want to repeat the same value for a specific time in the Array.
Ex.
If In the Array I want to repeat 0 for 5 times then I can do by one line of code like below.
let fiveZeros = Array(repeating: "0", count: 5)
print(fiveZeros)
// Prints "["0", "0", "0", "0", "0"]"
init(repeating:count:) function used.
So I'm looking for any function or code that works in Flutter.
I do googling but didn't find a solution.
In dart you can use the filled
factory of List
.
final list = List.filled(5, 0);
print(list); //-> [0, 0, 0, 0, 0]
See more in the list docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With