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.
This commit is contained in:
parent
6d58770499
commit
71e689f450
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user