From 71e689f45089ede8760fa0c19fce987b0e85e48f Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Fri, 1 Apr 2016 16:10:27 -0700 Subject: [PATCH] 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. --- packages/flutter/lib/src/widgets/basic.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index bc58e6f8df4..88f078d85aa 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -1682,7 +1682,7 @@ class DefaultTextStyle extends InheritedWidget { /// The style from the closest instance of this class that encloses the given context. static TextStyle of(BuildContext context) { DefaultTextStyle result = context.inheritFromWidgetOfExactType(DefaultTextStyle); - return result?.style; + return result?.style ?? const TextStyle(); } @override @@ -1716,7 +1716,7 @@ class Text extends StatelessWidget { TextStyle _getEffectiveStyle(BuildContext context) { if (style == null || style.inherit) - return DefaultTextStyle.of(context)?.merge(style) ?? style; + return DefaultTextStyle.of(context).merge(style); else return style; }