A list of widgets is placed where Flutter expects one widget
The element type 'List<Widget>' can't be assigned to the list type 'Widget'.Short answer
Dart found a whole list inside a list literal that holds single widgets. Put the items in with the spread operator (...), so the list is unpacked instead of nested. The same applies to an if element that builds several widgets, and to the result of map(), which is an Iterable and needs a spread or toList().
Fix it fast
1Find out which cause you have
Open the line the analyzer underlines and look at the value you pass. If it is a variable or method that returns a list, or a map(...) call, one of the causes below applies. The analyzer output lists every such line.
flutter analyze2Match what you see, then jump to its fix
- 1
The element type 'List<Widget>' can't be assigned to the list type 'Widget'.A list sits inside children next to single widgetsFix - 2
The element type 'List<Widget>' can't be assigned to the list type 'Widget' on a line that starts with ifA collection if produces several widgets without a spreadFix - 3
The element type 'Iterable<Widget>' can't be assigned to the list type 'Widget'.map() returns an Iterable, not a list of widgetsFix - 4
Error on the spread line saying the value can't be nullThe list can be nullFix
- 1
What does the error look like?
The element type 'List<Widget>' can't be assigned to the list type 'Widget'.The argument type 'List<Widget>' can't be assigned to the parameter type 'Widget'.The element type 'Iterable<Widget>' can't be assigned to the list type 'Widget'.
Cause 1 of 4
A list sits inside children next to single widgets
1Check
children expects a list whose items are widgets. If one item is itself a list (a helper method such as buildButtons() that returns List<Widget>), the list is nested, and Dart rejects it.
grep -n "children:" -A8 lib/screens/home_screen.dart2Fix
Add the spread operator in front of the list. It inserts each value of the list into the surrounding list.
Column(
children: [
const Text('Title'),
...buildButtons(),
const Text('Footer'),
],
)3Verify
The analyzer no longer reports the line.
flutter analyzeConfirmed by dart.dev
Cause 2 of 4
A collection if produces several widgets without a spread
1Check
An if element inside a list literal adds one element. If its branch is a list of widgets, that list is again nested.
grep -n "if (" -A4 lib/screens/home_screen.dart2Fix
Write the spread directly inside the if element, so the branch adds several values.
Column(
children: [
if (isLoggedIn) ...[
const Text('Welcome'),
const Text('Your orders'),
],
const Text('Footer'),
],
)3Verify
Run the analyzer again.
flutter analyzeConfirmed by dart.dev
Cause 3 of 4
map() returns an Iterable, not a list of widgets
1Check
Iterable.map returns a lazy Iterable. Placing it as an item of children nests it, and passing it where a List<Widget> is required fails too.
grep -n ".map(" lib/screens/home_screen.dart2Fix
Spread the mapped values into the list. When a real List<Widget> is needed, call toList() at the end.
Column(
children: [
...items.map((item) => ListTile(title: Text(item.name))),
],
)
// when a List<Widget> is required:
final tiles = items.map((item) => ListTile(title: Text(item.name))).toList();3Verify
Run the analyzer and open the screen.
flutter analyzeConfirmed by api.dart.dev
Cause 4 of 4
The list can be null
1Check
With null safety, a spread (...) on a value that might be null is not allowed.
grep -n "\.\.\." lib/screens/home_screen.dart2Fix
Use the null-aware spread. It adds nothing when the list is null.
List<Widget>? extras;
Column(
children: [
const Text('Title'),
...?extras,
],
)3Verify
Run the analyzer.
flutter analyzeConfirmed by dart.dev
How do I stop it coming back?
- Make helper methods return a single Widget, or document clearly that they return a list and spread them at the call site.
- Use ...[ ] inside if and for elements whenever a branch adds more than one widget.
- Run flutter analyze before each commit so a nested list shows up as an error at once.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Mobile apps
AudioCache has no play method after updating audioplayers
The method 'play' isn't defined for the type 'AudioCache'.
Since audioplayers 1.0, AudioCache only turns asset files into local files and caches them.
2 causes, each with a fixMobile apps
Flutter Bloc throws that emit was called after the event handler completed
emit was called after an event handler completed normally.
Each on<Event> handler gets its own Emitter, and it stops working the moment the handler's returned Future completes.
2 causes, each with a fixMobile apps
analysis_options.yaml: the URI it includes can't be found
include_file_not_found
The analyzer reports include_file_not_found when the file named after include: in analysis_options.yaml does not resolve.
2 causes, each with a fixMobile apps
Dart error: the body might complete normally and return null for a non-nullable type
body_might_complete_normally
Dart found a path through your function or callback that reaches the closing brace without a return.
3 causes, each with a fixMobile apps
Dart throws ConcurrentModificationError while looping over a list
ConcurrentModificationError
Dart throws this when a collection changes size while something iterates it.
2 causes, each with a fixMobile apps
Dart cannot turn a compact timestamp like 20201101153000 into a DateTime
FormatException: Invalid date format
DateTime.parse accepts a subset of ISO 8601, and a time part must be introduced by T or a space.
2 causes, each with a fix