Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions lib/src/internals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class Parser {
final TextStyle? defaultTextStyle;

TextSpan _getTextSpan(String text, String style, TextStyle overrideStyle) {
final Iterable<String> rules =
style.split(';').where((String item) => item.trim().isNotEmpty);
final Iterable<String> rules = style.split(';').where((String item) => item.trim().isNotEmpty);
TextStyle textStyle = DefaultTextStyle.of(context).style;
textStyle = textStyle.apply(color: const Color(0xff000000));
textStyle = textStyle.merge(defaultTextStyle);
Expand Down Expand Up @@ -161,7 +160,7 @@ class Parser {
case 'h1':
double h1;
if (defaultFontSize == null) {
h1 = Theme.of(context).textTheme.headline5?.fontSize ?? 24.0;
h1 = Theme.of(context).textTheme.headlineLarge?.fontSize ?? 24.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be headlineSmall

} else {
h1 = defaultFontSize * 2;
}
Expand All @@ -171,7 +170,7 @@ class Parser {
case 'h2':
double h2;
if (defaultFontSize == null) {
h2 = Theme.of(context).textTheme.headline6?.fontSize ?? 20.0;
h2 = Theme.of(context).textTheme.headlineLarge?.fontSize ?? 20.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be titleLarge

} else {
h2 = defaultFontSize * 1.5;
}
Expand All @@ -181,7 +180,7 @@ class Parser {
case 'h3':
double h3;
if (defaultFontSize == null) {
h3 = Theme.of(context).textTheme.subtitle1?.fontSize ?? 16.0;
h3 = Theme.of(context).textTheme.headlineMedium?.fontSize ?? 16.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be bodyLarge

} else {
h3 = defaultFontSize * 1.17;
}
Expand All @@ -191,7 +190,7 @@ class Parser {
case 'h4':
double h4;
if (defaultFontSize == null) {
h4 = Theme.of(context).textTheme.bodyText1?.fontSize ?? 16.0;
h4 = Theme.of(context).textTheme.headlineMedium?.fontSize ?? 16.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be bodyLarge

} else {
h4 = defaultFontSize;
}
Expand All @@ -201,7 +200,7 @@ class Parser {
case 'h5':
double h5;
if (defaultFontSize == null) {
h5 = Theme.of(context).textTheme.bodyText1?.fontSize ?? 16.0;
h5 = Theme.of(context).textTheme.headlineMedium?.fontSize ?? 16.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be bodyLarge

} else {
h5 = defaultFontSize * .83;
}
Expand All @@ -211,7 +210,7 @@ class Parser {
case 'h6':
double h6;
if (defaultFontSize == null) {
h6 = Theme.of(context).textTheme.bodyText2?.fontSize ?? 14.0;
h6 = Theme.of(context).textTheme.headlineSmall?.fontSize ?? 14.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be bodyMedium

} else {
h6 = defaultFontSize * .67;
}
Expand Down Expand Up @@ -251,8 +250,7 @@ class Parser {
break;

case 'a':
styles =
'''visit_link:__#TO_GET#__; text-decoration: underline; color: #4287f5;''';
styles = '''visit_link:__#TO_GET#__; text-decoration: underline; color: #4287f5;''';
break;

// dropping partial support for ul-li bullets
Expand Down Expand Up @@ -285,8 +283,7 @@ class Parser {
if (attribute.name == 'style') {
styles = '$styles;${attribute.value}';
} else if (attribute.name == 'href') {
styles = styles.replaceFirst('__#TO_GET#__',
attribute.value.replaceAll(':', '__#COLON#__'));
styles = styles.replaceFirst('__#TO_GET#__', attribute.value.replaceAll(':', '__#COLON#__'));
}
}
_stack.add(_Tag(event.name, styles, overrideStyles));
Expand Down Expand Up @@ -338,8 +335,7 @@ class Parser {
if (spans.isNotEmpty) {
final List<TextSpan> reversed = spans.reversed.toList();

while (reversed.isNotEmpty &&
(reversed.first.text == '\n\n' || reversed.first.text == '\n')) {
while (reversed.isNotEmpty && (reversed.first.text == '\n\n' || reversed.first.text == '\n')) {
reversed.removeAt(0);
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ dependencies:
flutter:
sdk: flutter
html_unescape: ^2.0.0
xml: ^6.1.0
xml: ^6.5.0

dev_dependencies:
flutter_lints: ^2.0.1
flutter_lints: ^4.0.0
flutter_test:
sdk: flutter

Expand Down