首页 > 解决方案 > Flutter Web:如何链接到网页上的特定行或段落

问题描述

如何获得在 Flutter web.xml 中引用页面特定部分(段落或选项卡)的能力。在传统的 Web url 中,这可以通过div使用#. 例如,在链接https://cloud.google.com/customers/featured/paypal#take-the-next-step中,链接直接指向div标记为take-the-next-step

有没有办法在 Flutter Web 中做到这一点?

标签: flutterflutter-web

解决方案


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.


推荐阅读