Reputation: 5064
Hi I am getting the following error while running the application What can be the possible reason for the issue?
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ The following assertion was thrown building Home(dirty, state: _HomeState#f7a67): 'package:flutter/src/widgets/framework.dart': Failed assertion: line 1639: '!children.any((Widget child) => child == null)': is not true.
Upvotes: 2
Views: 6121
Reputation: 21
In my case, the result of buildChildrenis null, or one element in the returned list is null.
Column column = new Column(
// center the children
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: buildChildren(context),
);
Upvotes: 0
Reputation: 11941
Might also get this problem if there is null in list of widgets:
Widget build() {
return new Column(
children: [
new Title(),
new Body(),
shouldShowFooter ? null : new Container()
]
);
}
To solve this:
bool notNull(Object o) => o != null;
Widget build() {
return new Column(
children: <Widget>[
new Title(),
new Body(),
shouldShowFooter ? new Footer() : new Container()
].where(notNull).toList(),
);
}
More info on it: https://github.com/flutter/flutter/issues/3783
Upvotes: 2
Reputation: 379
Faced the same problem a few days ago.
This happens when you forget to or miss to return the Widget.
Without seeing your code it's difficult to know the exact point of failure.
As far I am concerned, my previous code goes like:
@override
Widget build(BuildContext context) {
//....
new Column(
//.....
);
}
And after fixing it::
@override
Widget build(BuildContext context) {
//....
return new Column(
//.....
);
}
Hope this helps!
Upvotes: 10