Unverified Commit 59b2c5a3 authored by Gary Qian's avatar Gary Qian Committed by GitHub

Add null check in TextStyle.apply for TextBaseline (#54442)

parent f7ee7ae7
......@@ -842,7 +842,7 @@ class TextStyle with Diagnosticable {
fontStyle: fontStyle ?? this.fontStyle,
letterSpacing: letterSpacing == null ? null : letterSpacing * letterSpacingFactor + letterSpacingDelta,
wordSpacing: wordSpacing == null ? null : wordSpacing * wordSpacingFactor + wordSpacingDelta,
textBaseline: textBaseline,
textBaseline: textBaseline ?? this.textBaseline,
height: height == null ? null : height * heightFactor + heightDelta,
locale: locale ?? this.locale,
foreground: foreground,
......
......@@ -374,14 +374,16 @@ void main() {
});
test('TextStyle apply', () {
const TextStyle style = TextStyle(fontSize: 10);
expect(style.apply().shadows, isNull);
const TextStyle style = TextStyle(fontSize: 10, shadows: <ui.Shadow>[], fontStyle: FontStyle.normal, fontFeatures: <ui.FontFeature>[], textBaseline: TextBaseline.alphabetic);
expect(style.apply().shadows, const <ui.Shadow>[]);
expect(style.apply(shadows: const <ui.Shadow>[ui.Shadow(blurRadius: 2.0)]).shadows, const <ui.Shadow>[ui.Shadow(blurRadius: 2.0)]);
expect(style.apply().fontStyle, isNull);
expect(style.apply().fontStyle, FontStyle.normal);
expect(style.apply(fontStyle: FontStyle.italic).fontStyle, FontStyle.italic);
expect(style.apply().locale, isNull);
expect(style.apply(locale: const Locale.fromSubtags(languageCode: 'es')).locale, const Locale.fromSubtags(languageCode: 'es'));
expect(style.apply().fontFeatures, isNull);
expect(style.apply().fontFeatures, const <ui.FontFeature>[]);
expect(style.apply(fontFeatures: const <ui.FontFeature>[ui.FontFeature.enable('test')]).fontFeatures, const <ui.FontFeature>[ui.FontFeature.enable('test')]);
expect(style.apply().textBaseline, TextBaseline.alphabetic);
expect(style.apply(textBaseline: TextBaseline.ideographic).textBaseline, TextBaseline.ideographic);
});
}
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