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 @@ -3,19 +3,28 @@ import 'package:flutter/widgets.dart';
33import 'package:flutter_html/src/styled_element.dart' ;
44
55class AnchorKey extends GlobalKey {
6+ static final Set <AnchorKey > _registry = < AnchorKey > {};
7+
68 final Key parentKey;
79 final String id;
810
911 const AnchorKey ._(this .parentKey, this .id) : super .constructor ();
1012
1113 static AnchorKey ? of (Key ? parentKey, StyledElement ? id) {
12- return forId (parentKey, id? .elementId);
14+ final key = forId (parentKey, id? .elementId);
15+ if (key == null || _registry.contains (key)) {
16+ // Invalid id or already created a key with this id: silently ignore
17+ return null ;
18+ }
19+ _registry.add (key);
20+ return key;
1321 }
1422
1523 static AnchorKey ? forId (Key ? parentKey, String ? id) {
1624 if (parentKey == null || id == null || id.isEmpty || id == "[[No ID]]" ) {
1725 return null ;
1826 }
27+
1928 return AnchorKey ._(parentKey, id);
2029 }
2130
You can’t perform that action at this time.
0 commit comments