Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

480
Views
¿Cómo abro un navegador web (URL) desde mi código Flutter?

Estoy creando una aplicación de Flutter y me gustaría abrir una URL en un navegador web o en una ventana del navegador (en respuesta a un toque de botón). ¿Cómo puedo hacer esto?

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

TL;RD

Esto ahora se implementa como complemento

 const url = "https://flutter.io"; if (await canLaunch(url)) await launch(url); else // can't launch url, there is some error throw "Could not launch $url";

Ejemplo completo:

 import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; void main() { runApp(new Scaffold( body: new Center( child: new RaisedButton( onPressed: _launchURL, child: new Text('Show Flutter homepage'), ), ), )); } _launchURL() async { const url = 'https://flutter.io'; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } }

En pubspec.yaml

 dependencies: url_launcher: ^5.7.10

Caracteres especiales:

Si el valor de la url contiene espacios u otros valores que ahora están permitidos en las URL, utilice

Uri.encodeFull(urlString) o Uri.encodeComponent(urlString) y pase el valor resultante en su lugar.

about 4 years ago · Santiago Trujillo Report

0

Si apunta a SDK 30 o superior, canLaunch devolverá falso de forma predeterminada debido a los cambios de visibilidad del paquete: https://developer.android.com/training/basics/intents/package-visibility

en androidManifest.xml deberá agregar lo siguiente directamente debajo de <manifest> :

 <queries> <intent> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" /> </intent> </queries>

Entonces lo siguiente debería ser una palabra

 const url = "https://flutter.io"; if (await canLaunch(url)){ await launch(url); } else { // can't launch url }
about 4 years ago · Santiago Trujillo Report

0

Para aleteo:

Como se describe anteriormente por Günter Zöchbauer

Para Flutter Web:

 import 'dart:html' as html;

Luego usa:

 html.window.open(url, name);

Asegúrate de ejecutar flutter clean si la import no se resuelve.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!