flutter_widget_from_html
flutter_widget_from_html copied to clipboard
scrollToAnchor from outside the HtmlWidget?
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.
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');