简体   繁体   中英

Hyperlink in flutter?

这就是我想做的 I'm new to flutter and programming for phone apps in general so bear with me. I have a list when I press something on that list(tap on an element) it will open a new screen with description of that pressed thing(element). Inside that description there is a 'link'(name of a another element that belongs to aforementioned list) when I press that 'link' I would like to go to that elements description. Is that something that is done with navigator?

I tried url_launcher that launches link on web browser(links provided with api exist on webpage). I want that to happen internally.

You can use webview_flutter plugin.

When press the link, pass the link to WebViewExample .

Ex:

import 'dart:io';    
import 'package:flutter/cupertino.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebViewExample extends StatefulWidget {
  final url;
  const WebViewExample(this.url, {Key? key}) : super(key: key);

  @override
  _WebViewExampleState createState() => _WebViewExampleState();
}

class _WebViewExampleState extends State<WebViewExample> {
  @override
  void initState() {
    super.initState();
    // Enable virtual display.
    if (Platform.isAndroid) WebView.platform = AndroidWebView();
  }

  @override
  Widget build(BuildContext context) {
    return WebView(
      initialUrl: widget.url,
    );
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM