Skip to content

Commit

Permalink
improve error messages on Text constructors (flutter#28709)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield authored Mar 1, 2019
1 parent a3683d3 commit be083da
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/flutter/lib/src/widgets/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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);

Expand Down

0 comments on commit be083da

Please sign in to comment.