flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.76k stars 26.77k forks source link

Proposal to improve `List` readability in this repository #146600

Closed nate-thegrate closed 1 month ago

nate-thegrate commented 2 months ago

Now that the switch expressions issue is close to being wrapped up (yay!), I think it'd be nice to embark on a similar cleanup for collection types.

Control Flow Collections

// before
final result = <Object>[];
result.add(value1);
if (condition) {
  result.add(value2);
}
if (list != null) {
  result.addAll(list!);
}
return result;

// after
return <Object>[
  value1,
  if (condition) value2,
  ...?list,
];
nate-thegrate commented 1 month ago

Originally I was thinking about refactoring a bunch of itemBuilder callbacks after the control flow collections were done, but it's a lot of hassle (both the refactoring and the review process) for barely any benefit.

I'm going to mark this as "completed" and move on to more exciting stuff! :)

github-actions[bot] commented 4 weeks ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.