le mie informazioni di contatto
Posta[email protected]
2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Flutter può utilizzare il browser per aprire un URL dopo aver fatto clic sul testo, ad esempio "www.baidu.com". Questo può essere fatto utilizzando url_launcher
pacchetto da raggiungere.Per prima cosa devi aggiungere il tuopubspec.yaml
Aggiungi al fileurl_launcher
fare affidamento.
url_launcher: ^6.3.0
Di seguito è riportato il codice di esempio
- import 'package:flutter/material.dart';
- import 'package:url_launcher/url_launcher.dart';
-
- final Uri _url = Uri.parse('https://www.baidu.com');
-
- void main() => runApp(
- const MaterialApp(
- home: Material(
- child: Center(
- child: ElevatedButton(
- onPressed: _launchUrl,
- child: Text('点击打开百度'),
- ),
- ),
- ),
- ),
- );
-
- Future<void> _launchUrl() async {
- if (!await launchUrl(_url)) {
- throw Exception('Could not launch $_url');
- }
- }