From 59c3ecdcc66d4223bb79de4b4590deed39461c37 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 4 Dec 2015 14:47:51 -0800 Subject: [PATCH] Improve the asset for build functions that return null Fixes #689 --- packages/flutter/lib/src/widgets/framework.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 2ce76cc894..69f76774b5 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -416,7 +416,7 @@ abstract class State { /// Called when an Inherited widget in the ancestor chain has changed. Usually /// there is nothing to do here; whenever this is called, build() is also - /// called. + /// called. void dependenciesChanged(Type affectedWidgetType) { } String toString() { @@ -1094,7 +1094,17 @@ abstract class ComponentElement extends BuildableElement { Widget built; try { built = _builder(this); - assert(built != null); + assert(() { + if (built == null) { + debugPrint('Widget: $widget'); + assert(() { + 'A build function returned null. Build functions must never return null.' + 'The offending widget is displayed above.'; + return false; + }); + } + return true; + }); } catch (e, stack) { _debugReportException('building $_widget', e, stack); built = new ErrorWidget();