Devrim Kaymaz
 · CEO of Phantom AI Fitness

Open app (Spotify) using URL_Launcher

Custom Code

Hello everyone!

I saw that in Flutterflow packages, there is URL_Launcher, it's top because in my app I want to offer “shortcuts” to open Spotify, Google Maps etc.. These shortcuts can be customized by the user. However, I've managed to build the app and test it on a real device via Testflight but it doesn't work, even though Spotify and Google Maps are installed.

I used Flutterflow's Copilot Code and it generated this code for me.

Any ideas? I'm also looking for the ability to control music like the Control Center on iOS (so it doesn't matter what the music source is) if anyone has already tested something.

Image with list of custom shortcuts

What have you tried so far?

This code

// Automatic FlutterFlow imports

import '/backend/backend.dart';

import '/flutter_flow/flutter_flow_theme.dart';

import '/flutter_flow/flutter_flow_util.dart';

import '/custom_code/actions/index.dart'; // Imports other custom actions

import '/flutter_flow/custom_functions.dart'; // Imports custom functions

import 'package:flutter/material.dart';

// Begin custom action code

// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:url_launcher/url_launcher.dart';

Future<void> openSpotify() async {

// Schéma d'URL pour Spotify

const String url = 'spotify://'; // URL scheme for Spotify app

final Uri uri = Uri.parse(url);

// Vérifier si l'URL peut être ouverte

if (await canLaunchUrl(uri)) {

// Lancer l'URL

await launchUrl(uri);

} else {

throw 'Impossible d\'ouvrir Spotify.';

}

}

And Docs and ChatGPT

Did you check FlutterFlow's Documentation for this topic?
Yes
1