#201 fix for hr (horizontal rule) when alongside other markup (#216)
diff --git a/packages/flutter_markdown/lib/src/builder.dart b/packages/flutter_markdown/lib/src/builder.dart
index 7d4942b..b2f2a06 100644
--- a/packages/flutter_markdown/lib/src/builder.dart
+++ b/packages/flutter_markdown/lib/src/builder.dart
@@ -297,9 +297,8 @@
child: child,
);
} else if (tag == 'hr') {
- child = DecoratedBox(
- decoration: styleSheet.horizontalRuleDecoration,
- child: child,
+ child = Container(
+ decoration: styleSheet.horizontalRuleDecoration
);
}
diff --git a/packages/flutter_markdown/test/flutter_markdown_test.dart b/packages/flutter_markdown/test/flutter_markdown_test.dart
index bdf14bb..20a1120 100644
--- a/packages/flutter_markdown/test/flutter_markdown_test.dart
+++ b/packages/flutter_markdown/test/flutter_markdown_test.dart
@@ -148,11 +148,87 @@
]);
});
- testWidgets('Horizontal Rule', (WidgetTester tester) async {
- await tester.pumpWidget(_boilerplate(const MarkdownBody(data: '-----')));
+ testWidgets('Horizontal Rule - 3 hyphen', (WidgetTester tester) async {
+
+ await tester.pumpWidget(
+ _boilerplate(MarkdownBody(
+ data: '---'))
+ );
final Iterable<Widget> widgets = tester.allWidgets;
- _expectWidgetTypes(widgets, <Type>[Directionality, MarkdownBody, DecoratedBox, SizedBox]);
+ _expectWidgetTypes(widgets, <Type>[
+ Directionality,
+ MarkdownBody,
+ Container,
+ DecoratedBox,
+ Padding,
+ LimitedBox,
+ ConstrainedBox
+ ]);
+
+ });
+
+ testWidgets('Horizontal Rule - 5 hyphen', (WidgetTester tester) async {
+
+ await tester.pumpWidget(
+ _boilerplate(MarkdownBody(
+ data: '-----'))
+ );
+
+ final Iterable<Widget> widgets = tester.allWidgets;
+ _expectWidgetTypes(widgets, <Type>[
+ Directionality,
+ MarkdownBody,
+ Container,
+ DecoratedBox,
+ Padding,
+ LimitedBox,
+ ConstrainedBox
+ ]);
+
+ });
+
+ testWidgets('Horizontal Rule - 3 asterisk', (WidgetTester tester) async {
+
+ await tester.pumpWidget(
+ _boilerplate(MarkdownBody(
+ data: '* * *'))
+ );
+
+ final Iterable<Widget> widgets = tester.allWidgets;
+ _expectWidgetTypes(widgets, <Type>[
+ Directionality,
+ MarkdownBody,
+ Container,
+ DecoratedBox,
+ Padding,
+ LimitedBox,
+ ConstrainedBox
+ ]);
+
+ });
+
+ testWidgets('Horizontal Rule * * * alongside text Markdown', (WidgetTester tester) async {
+ await tester.pumpWidget(_boilerplate(
+ MarkdownBody(data: '# h1\n ## h2\n* * *')));
+ final Iterable<Widget> widgets = tester.allWidgets;
+ _expectWidgetTypes(widgets, <Type>[
+ Directionality,
+ MarkdownBody,
+ Column,
+ Column,
+ Wrap,
+ RichText,
+ SizedBox,
+ Column,
+ Wrap,
+ RichText,
+ SizedBox,
+ Container,
+ DecoratedBox,
+ Padding,
+ LimitedBox,
+ ConstrainedBox]);
});
testWidgets('Scrollable wrapping', (WidgetTester tester) async {