Commit 71e689f4 authored by Ian Hickson's avatar Ian Hickson

Have a default default text style.

This way, widgets that try to use the DefaultTextStyle don't have to

handle the case where there isn't an explicit default.
parent 6d587704
...@@ -1682,7 +1682,7 @@ class DefaultTextStyle extends InheritedWidget { ...@@ -1682,7 +1682,7 @@ class DefaultTextStyle extends InheritedWidget {
/// The style from the closest instance of this class that encloses the given context. /// The style from the closest instance of this class that encloses the given context.
static TextStyle of(BuildContext context) { static TextStyle of(BuildContext context) {
DefaultTextStyle result = context.inheritFromWidgetOfExactType(DefaultTextStyle); DefaultTextStyle result = context.inheritFromWidgetOfExactType(DefaultTextStyle);
return result?.style; return result?.style ?? const TextStyle();
} }
@override @override
...@@ -1716,7 +1716,7 @@ class Text extends StatelessWidget { ...@@ -1716,7 +1716,7 @@ class Text extends StatelessWidget {
TextStyle _getEffectiveStyle(BuildContext context) { TextStyle _getEffectiveStyle(BuildContext context) {
if (style == null || style.inherit) if (style == null || style.inherit)
return DefaultTextStyle.of(context)?.merge(style) ?? style; return DefaultTextStyle.of(context).merge(style);
else else
return style; return style;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment