Flutter Web:如何链接到网页上的特定行或段落 [英] Flutter Web : How to Link to a Specific Line or Paragraph on a Web Page
问题描述
我如何能够在Flutter网站中引用页面的特定部分(段落或选项卡).在传统的网址中,可以通过将 div
锚定为带有#
的引用来实现.例如在链接 https://cloud.google.com/customers/featured/paypal#take-the-next-step
中,该链接直接指向 div
被标记为后续步骤
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
在Flutter Web中有没有办法做到这一点?
Is there a way to do this in Flutter Web yet ?
推荐答案
您可以获取当前URL并将其解析为URL末尾的参数.您可以使用以下代码获取当前网址:
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;
使用已解析的参数,可以使用 ScrollController
(或用于更改页面位置的任何方法)将页面上的位置更改为屏幕上所需的位置.
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.
这篇关于Flutter Web:如何链接到网页上的特定行或段落的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!