flutter_widget_from_html icon indicating copy to clipboard operation
flutter_widget_from_html copied to clipboard

scrollToAnchor from outside the HtmlWidget?

Open giorgio79 opened this issue 10 months ago • 1 comments

Hello,

Would it be possible to scroll to an anchor from outside the html widget? I have a side panel with a listview where users can tap and I would like to scroll inside the HtmlWidget to the anchor.

giorgio79 avatar Mar 09 '25 13:03 giorgio79

Yes, you can use GlobalKey for that.

// prepare the key
final htmlKey = GlobalKey<HtmlWidgetState>();

// render widget
HtmlWidget(html, key: htmlKey)

// scroll to some ID
htmlKey.currentState?.scrollToAnchor('some-id');

daohoangson avatar Mar 16 '25 19:03 daohoangson