Flutter Web : How to Link to a Specific Line or Paragraph on a Web Page

孤者浪人 提交于 2021-01-29 16:44:39

问题


How do I get the ability to reference to a particular part of the page (a paragraph or a tab) in Flutter web. In traditional web url, this is made possible by anchoring the div to be references with a #. For e.g. in the link https://cloud.google.com/customers/featured/paypal#take-the-next-step, the link takes as directly to the div that is tagged as take-the-next-step

Is there a way to do this in Flutter Web yet ?


回答1:


You can get the current URL and parse it for the parameter at the end of the URL. You can get the current URL with this code:

import 'dart:html';

var url = window.location.href;

Using the parameter that you have parsed, you can change the position on the page with your ScrollController(or whatever method you're using to change page position) to the desired place on screen.



来源:https://stackoverflow.com/questions/62683620/flutter-web-how-to-link-to-a-specific-line-or-paragraph-on-a-web-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!