From be083da9c65667e04e33f5aa813f94eac7fbf1c4 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 1 Mar 2019 10:20:08 -0800 Subject: [PATCH] improve error messages on Text constructors (#28709) --- packages/flutter/lib/src/widgets/text.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/widgets/text.dart b/packages/flutter/lib/src/widgets/text.dart index 33687c0cb6d..5991ca55b50 100644 --- a/packages/flutter/lib/src/widgets/text.dart +++ b/packages/flutter/lib/src/widgets/text.dart @@ -222,6 +222,8 @@ class Text extends StatelessWidget { /// /// If the [style] argument is null, the text will use the style from the /// closest enclosing [DefaultTextStyle]. + /// + /// The [data] parameter must not be null. const Text(this.data, { Key key, this.style, @@ -234,11 +236,16 @@ class Text extends StatelessWidget { this.textScaleFactor, this.maxLines, this.semanticsLabel, - }) : assert(data != null), + }) : assert( + data != null, + 'A non-null String must be provided to a Text widget.', + ), textSpan = null, super(key: key); /// Creates a text widget with a [TextSpan]. + /// + /// The [textSpan] parameter must not be null. const Text.rich(this.textSpan, { Key key, this.style, @@ -251,7 +258,10 @@ class Text extends StatelessWidget { this.textScaleFactor, this.maxLines, this.semanticsLabel, - }) : assert(textSpan != null), + }) : assert( + textSpan != null, + 'A non-null TextSpan must be provided to a Text.rich widget.', + ), data = null, super(key: key);