Consider the following situation, where you now have three Text Widgets lists:

List<Widget> northAmericanCountries = [
  Text('USA'),
  Text('Canada')];List<Widget> asianCountries = [
  Text('India'),
  Text('China')];List<Widget> europeanCountries = [
  Text('France'),
  Text('Germany'),
  Text('Italy')];Copy the code


If we add three lists to a Row Widget, we usually do this:

Row( children: northAmericanCountries .. addAll(asianCountries) .. addAll(europeanCountries), )Copy the code


Now there is a need to put asianCountries before northAmericanCountries, and you need to change it like this:

Row( children: asianCountries .. addAll(northAmericanCountries) .. addAll(europeanCountries), )Copy the code

Each time you need to reorder the addAll methods, which is very inconvenient.


So, our… Here comes the operator! With it you can easily do the following:

Row(
  children: [
              ...northAmericanCountries,
              ...asianCountries,
              ...europeanCountries
            ],
)
Copy the code

What you need to do to reorder:

Row(
  children: [
              ...asianCountries,
              ...northAmericanCountries,
              ...europeanCountries
            ],
)
Copy the code


An aside:

// Or you could write it this way
Row(
  children: [asianCountries]+[northAmericanCountries]+[europeanCountries],
)
Copy the code