File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,7 @@ class SelectableHtml extends StatelessWidget {
213213
214214 SelectableHtml ({
215215 Key ? key,
216+ GlobalKey ? anchorKey,
216217 required this .data,
217218 this .onLinkTap,
218219 this .onAnchorTap,
@@ -221,10 +222,13 @@ class SelectableHtml extends StatelessWidget {
221222 this .style = const {},
222223 this .tagsList = const [],
223224 }) : document = null ,
225+ assert (data != null ),
226+ _anchorKey = anchorKey ?? GlobalKey (),
224227 super (key: key);
225228
226229 SelectableHtml .fromDom ({
227230 Key ? key,
231+ GlobalKey ? anchorKey,
228232 required this .document,
229233 this .onLinkTap,
230234 this .onAnchorTap,
@@ -233,8 +237,13 @@ class SelectableHtml extends StatelessWidget {
233237 this .style = const {},
234238 this .tagsList = const [],
235239 }) : data = null ,
240+ assert (document != null ),
241+ _anchorKey = anchorKey ?? GlobalKey (),
236242 super (key: key);
237243
244+ /// A unique key for this Html widget to ensure uniqueness of anchors
245+ final GlobalKey _anchorKey;
246+
238247 /// The HTML data passed to the widget as a String
239248 final String ? data;
240249
@@ -271,7 +280,7 @@ class SelectableHtml extends StatelessWidget {
271280 return Container (
272281 width: width,
273282 child: HtmlParser (
274- key: null ,
283+ key: _anchorKey ,
275284 htmlData: doc,
276285 onLinkTap: onLinkTap,
277286 onAnchorTap: onAnchorTap,
You can’t perform that action at this time.
0 commit comments