问题
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