Skip to content

Commit 974933e

Browse files
committed
Merge remote-tracking branch 'tneotia/feature/scroll-physics' into everything
2 parents 33242a5 + 71998f8 commit 974933e

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/flutter_html.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ class SelectableHtml extends StatelessWidget {
221221
this.shrinkWrap = false,
222222
this.style = const {},
223223
this.tagsList = const [],
224-
this.selectionControls
224+
this.selectionControls,
225+
this.scrollPhysics,
225226
}) : document = null,
226227
assert(data != null),
227228
_anchorKey = anchorKey ?? GlobalKey(),
@@ -237,7 +238,8 @@ class SelectableHtml extends StatelessWidget {
237238
this.shrinkWrap = false,
238239
this.style = const {},
239240
this.tagsList = const [],
240-
this.selectionControls
241+
this.selectionControls,
242+
this.scrollPhysics,
241243
}) : data = null,
242244
assert(document != null),
243245
_anchorKey = anchorKey ?? GlobalKey(),
@@ -276,6 +278,9 @@ class SelectableHtml extends StatelessWidget {
276278
/// options
277279
final TextSelectionControls? selectionControls;
278280

281+
/// Allows you to override the default scrollPhysics for [SelectableText.rich]
282+
final ScrollPhysics? scrollPhysics;
283+
279284
static List<String> get tags => new List<String>.from(SELECTABLE_ELEMENTS);
280285

281286
@override
@@ -302,6 +307,7 @@ class SelectableHtml extends StatelessWidget {
302307
tagsList: tagsList.isEmpty ? SelectableHtml.tags : tagsList,
303308
navigationDelegateForIframe: null,
304309
selectionControls: selectionControls,
310+
scrollPhysics: scrollPhysics,
305311
),
306312
);
307313
}

lib/html_parser.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class HtmlParser extends StatelessWidget {
5959
final NavigationDelegate? navigationDelegateForIframe;
6060
final OnTap? _onAnchorTap;
6161
final TextSelectionControls? selectionControls;
62+
final ScrollPhysics? scrollPhysics;
6263

6364
HtmlParser({
6465
required this.key,
@@ -76,7 +77,8 @@ class HtmlParser extends StatelessWidget {
7677
required this.imageRenders,
7778
required this.tagsList,
7879
required this.navigationDelegateForIframe,
79-
this.selectionControls
80+
this.selectionControls,
81+
this.scrollPhysics,
8082
}) : this._onAnchorTap = onAnchorTap != null
8183
? onAnchorTap
8284
: key != null
@@ -128,6 +130,7 @@ class HtmlParser extends StatelessWidget {
128130
style: cleanedTree.style,
129131
),
130132
selectionControls: selectionControls,
133+
scrollPhysics: scrollPhysics,
131134
);
132135
}
133136
return StyledText(
@@ -1073,6 +1076,7 @@ class StyledText extends StatelessWidget {
10731076
final AnchorKey? key;
10741077
final bool _selectable;
10751078
final TextSelectionControls? selectionControls;
1079+
final ScrollPhysics? scrollPhysics;
10761080

10771081
const StyledText({
10781082
required this.textSpan,
@@ -1081,6 +1085,7 @@ class StyledText extends StatelessWidget {
10811085
required this.renderContext,
10821086
this.key,
10831087
this.selectionControls,
1088+
this.scrollPhysics,
10841089
}) : _selectable = false,
10851090
super(key: key);
10861091

@@ -1090,7 +1095,8 @@ class StyledText extends StatelessWidget {
10901095
this.textScaleFactor = 1.0,
10911096
required this.renderContext,
10921097
this.key,
1093-
this.selectionControls
1098+
this.selectionControls,
1099+
this.scrollPhysics,
10941100
}) : textSpan = textSpan,
10951101
_selectable = true,
10961102
super(key: key);
@@ -1106,6 +1112,7 @@ class StyledText extends StatelessWidget {
11061112
textScaleFactor: textScaleFactor,
11071113
maxLines: style.maxLines,
11081114
selectionControls: selectionControls,
1115+
scrollPhysics: scrollPhysics,
11091116
);
11101117
}
11111118
return SizedBox(

0 commit comments

Comments
 (0)