mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
improve error messages on Text constructors (#28709)
This commit is contained in:
parent
a3683d303e
commit
be083da9c6
@ -222,6 +222,8 @@ class Text extends StatelessWidget {
|
|||||||
///
|
///
|
||||||
/// If the [style] argument is null, the text will use the style from the
|
/// If the [style] argument is null, the text will use the style from the
|
||||||
/// closest enclosing [DefaultTextStyle].
|
/// closest enclosing [DefaultTextStyle].
|
||||||
|
///
|
||||||
|
/// The [data] parameter must not be null.
|
||||||
const Text(this.data, {
|
const Text(this.data, {
|
||||||
Key key,
|
Key key,
|
||||||
this.style,
|
this.style,
|
||||||
@ -234,11 +236,16 @@ class Text extends StatelessWidget {
|
|||||||
this.textScaleFactor,
|
this.textScaleFactor,
|
||||||
this.maxLines,
|
this.maxLines,
|
||||||
this.semanticsLabel,
|
this.semanticsLabel,
|
||||||
}) : assert(data != null),
|
}) : assert(
|
||||||
|
data != null,
|
||||||
|
'A non-null String must be provided to a Text widget.',
|
||||||
|
),
|
||||||
textSpan = null,
|
textSpan = null,
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
/// Creates a text widget with a [TextSpan].
|
/// Creates a text widget with a [TextSpan].
|
||||||
|
///
|
||||||
|
/// The [textSpan] parameter must not be null.
|
||||||
const Text.rich(this.textSpan, {
|
const Text.rich(this.textSpan, {
|
||||||
Key key,
|
Key key,
|
||||||
this.style,
|
this.style,
|
||||||
@ -251,7 +258,10 @@ class Text extends StatelessWidget {
|
|||||||
this.textScaleFactor,
|
this.textScaleFactor,
|
||||||
this.maxLines,
|
this.maxLines,
|
||||||
this.semanticsLabel,
|
this.semanticsLabel,
|
||||||
}) : assert(textSpan != null),
|
}) : assert(
|
||||||
|
textSpan != null,
|
||||||
|
'A non-null TextSpan must be provided to a Text.rich widget.',
|
||||||
|
),
|
||||||
data = null,
|
data = null,
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user