[flutter_markdown] Fix issue where Scrollbars disappear when multiple code blocks are specified in the same markdown
diff --git a/packages/flutter_markdown/lib/src/builder.dart b/packages/flutter_markdown/lib/src/builder.dart
index b89ef2e..fff7f39 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 preScrollController = 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)),