Let's say I have an empty list. If I want to add a certain number of letters "g" to this list. for example 30 40 etc. the number I send may change. Is there a way to do this in one go without using a loop? What is it, if any?
https://api.flutter.dev/flutter/dart-core/List/fillRange.html I need a method like fillRange. FillRange does not work on an empty list.
CodePudding user response:
If the list is empty, don't bother using it. Just generate a new list with List.filled:
final list = List.filled(30, 'g');