mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 23:03:11 +08:00
[flutter_markdown] Add ScrollController to pre block Scrollbar (#3821)
Add ScrollController to `pre` block Scrollbar Fixes https://github.com/flutter/flutter/issues/116176
This commit is contained in:

committed by
GitHub

parent
6c7c2cc1ee
commit
ff656d8b8b
@ -1,5 +1,6 @@
|
||||
## NEXT
|
||||
## 0.6.15+1
|
||||
|
||||
* Fixes 'The Scrollbar's ScrollController has no ScrollPosition attached' exception when scrolling scrollable code blocks.
|
||||
* Fixes stale ignore: prefer_const_constructors.
|
||||
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
|
||||
|
||||
|
@ -162,6 +162,7 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
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;
|
||||
@ -328,7 +329,9 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
.visitText(text, styleSheet.styles[_blocks.last.tag!]);
|
||||
} else if (_blocks.last.tag == 'pre') {
|
||||
child = Scrollbar(
|
||||
controller: _preScrollController,
|
||||
child: SingleChildScrollView(
|
||||
controller: _preScrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: styleSheet.codeblockPadding,
|
||||
child: _buildRichText(delegate.formatText(styleSheet, text.text)),
|
||||
|
@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output,
|
||||
formatted with simple Markdown tags.
|
||||
repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown
|
||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22
|
||||
version: 0.6.15
|
||||
version: 0.6.15+1
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
|
@ -27,7 +27,10 @@ void defineTests() {
|
||||
);
|
||||
|
||||
final Iterable<Widget> widgets = tester.allWidgets;
|
||||
expect(widgets.whereType<SingleChildScrollView>(), isNotEmpty);
|
||||
final Iterable<SingleChildScrollView> scrollViews =
|
||||
widgets.whereType<SingleChildScrollView>();
|
||||
expect(scrollViews, isNotEmpty);
|
||||
expect(scrollViews.first.controller, isNotNull);
|
||||
},
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user