Fix Scrollbars not showing up when multiple code blocks are in the same markdown.
diff --git a/packages/flutter_markdown/lib/src/builder.dart b/packages/flutter_markdown/lib/src/builder.dart
index b89ef2e..6f69518 100644
--- a/packages/flutter_markdown/lib/src/builder.dart
+++ b/packages/flutter_markdown/lib/src/builder.dart
@@ -174,7 +174,6 @@
final List<_TableElement> _tables = <_TableElement>[];
final List<_InlineElement> _inlines = <_InlineElement>[];
final List<GestureRecognizer> _linkHandlers = <GestureRecognizer>[];
- final ScrollController _preScrollController = ScrollController();
String? _currentBlockTag;
String? _lastVisitedTag;
bool _isInBlockquote = false;
@@ -347,10 +346,11 @@
child = builders[_blocks.last.tag!]!
.visitText(text, styleSheet.styles[_blocks.last.tag!]);
} else if (_blocks.last.tag == 'pre') {
+ final ScrollController ppreScrollController = ScrollController();
child = Scrollbar(
- controller: _preScrollController,
+ controller: preScrollController,
child: SingleChildScrollView(
- controller: _preScrollController,
+ controller: preScrollController,
scrollDirection: Axis.horizontal,
padding: styleSheet.codeblockPadding,
child: _buildRichText(delegate.formatText(styleSheet, text.text)),