diff --git a/packages/flutter_markdown/lib/src/builder.dart b/packages/flutter_markdown/lib/src/builder.dart index 7d4942b150..b2f2a06014 100644 --- a/packages/flutter_markdown/lib/src/builder.dart +++ b/packages/flutter_markdown/lib/src/builder.dart @@ -297,9 +297,8 @@ class MarkdownBuilder implements md.NodeVisitor { 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 bdf14bbe52..20a11205fd 100644 --- a/packages/flutter_markdown/test/flutter_markdown_test.dart +++ b/packages/flutter_markdown/test/flutter_markdown_test.dart @@ -148,11 +148,87 @@ void main() { ]); }); - 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 widgets = tester.allWidgets; - _expectWidgetTypes(widgets, [Directionality, MarkdownBody, DecoratedBox, SizedBox]); + _expectWidgetTypes(widgets, [ + Directionality, + MarkdownBody, + Container, + DecoratedBox, + Padding, + LimitedBox, + ConstrainedBox + ]); + + }); + + testWidgets('Horizontal Rule - 5 hyphen', (WidgetTester tester) async { + + await tester.pumpWidget( + _boilerplate(MarkdownBody( + data: '-----')) + ); + + final Iterable widgets = tester.allWidgets; + _expectWidgetTypes(widgets, [ + Directionality, + MarkdownBody, + Container, + DecoratedBox, + Padding, + LimitedBox, + ConstrainedBox + ]); + + }); + + testWidgets('Horizontal Rule - 3 asterisk', (WidgetTester tester) async { + + await tester.pumpWidget( + _boilerplate(MarkdownBody( + data: '* * *')) + ); + + final Iterable widgets = tester.allWidgets; + _expectWidgetTypes(widgets, [ + 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 widgets = tester.allWidgets; + _expectWidgetTypes(widgets, [ + Directionality, + MarkdownBody, + Column, + Column, + Wrap, + RichText, + SizedBox, + Column, + Wrap, + RichText, + SizedBox, + Container, + DecoratedBox, + Padding, + LimitedBox, + ConstrainedBox]); }); testWidgets('Scrollable wrapping', (WidgetTester tester) async {