Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/flutter_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ class SelectableHtml extends StatelessWidget {
this.shrinkWrap = false,
this.style = const {},
this.tagsList = const [],
this.selectionControls
this.selectionControls,
this.scrollPhysics,
}) : document = null,
assert(data != null),
_anchorKey = anchorKey ?? GlobalKey(),
Expand All @@ -237,7 +238,8 @@ class SelectableHtml extends StatelessWidget {
this.shrinkWrap = false,
this.style = const {},
this.tagsList = const [],
this.selectionControls
this.selectionControls,
this.scrollPhysics,
}) : data = null,
assert(document != null),
_anchorKey = anchorKey ?? GlobalKey(),
Expand Down Expand Up @@ -276,6 +278,9 @@ class SelectableHtml extends StatelessWidget {
/// options
final TextSelectionControls? selectionControls;

/// Allows you to override the default scrollPhysics for [SelectableText.rich]
final ScrollPhysics? scrollPhysics;

static List<String> get tags => new List<String>.from(SELECTABLE_ELEMENTS);

@override
Expand All @@ -302,6 +307,7 @@ class SelectableHtml extends StatelessWidget {
tagsList: tagsList.isEmpty ? SelectableHtml.tags : tagsList,
navigationDelegateForIframe: null,
selectionControls: selectionControls,
scrollPhysics: scrollPhysics,
),
);
}
Expand Down
11 changes: 9 additions & 2 deletions lib/html_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class HtmlParser extends StatelessWidget {
final NavigationDelegate? navigationDelegateForIframe;
final OnTap? _onAnchorTap;
final TextSelectionControls? selectionControls;
final ScrollPhysics? scrollPhysics;

HtmlParser({
required this.key,
Expand All @@ -76,7 +77,8 @@ class HtmlParser extends StatelessWidget {
required this.imageRenders,
required this.tagsList,
required this.navigationDelegateForIframe,
this.selectionControls
this.selectionControls,
this.scrollPhysics,
}) : this._onAnchorTap = onAnchorTap != null
? onAnchorTap
: key != null
Expand Down Expand Up @@ -128,6 +130,7 @@ class HtmlParser extends StatelessWidget {
style: cleanedTree.style,
),
selectionControls: selectionControls,
scrollPhysics: scrollPhysics,
);
}
return StyledText(
Expand Down Expand Up @@ -1074,6 +1077,7 @@ class StyledText extends StatelessWidget {
final AnchorKey? key;
final bool _selectable;
final TextSelectionControls? selectionControls;
final ScrollPhysics? scrollPhysics;

const StyledText({
required this.textSpan,
Expand All @@ -1082,6 +1086,7 @@ class StyledText extends StatelessWidget {
required this.renderContext,
this.key,
this.selectionControls,
this.scrollPhysics,
}) : _selectable = false,
super(key: key);

Expand All @@ -1091,7 +1096,8 @@ class StyledText extends StatelessWidget {
this.textScaleFactor = 1.0,
required this.renderContext,
this.key,
this.selectionControls
this.selectionControls,
this.scrollPhysics,
}) : textSpan = textSpan,
_selectable = true,
super(key: key);
Expand All @@ -1107,6 +1113,7 @@ class StyledText extends StatelessWidget {
textScaleFactor: textScaleFactor,
maxLines: style.maxLines,
selectionControls: selectionControls,
scrollPhysics: scrollPhysics,
);
}
return SizedBox(
Expand Down