import 'package:http/http.dart' as http; import 'dart:convert'; import 'dart:io'; // 1. Trigger the "remix" endpoint Future getRemix(File voice, String textInput, String percussionPattern) async { String url = "http://localhost:5000/remix"; //Replace with your API URL var request = http.MultipartRequest('POST', Uri.parse(url)); request.files.add(await http.MultipartFile.fromPath( 'voice', voice.path, )); request.fields['text'] = textInput; request.fields['percussion'] = percussionPattern; var response = await request.send(); if (response.statusCode == 200) { var res = await response.stream.bytesToString(); var decodedResponse = jsonDecode(res); if(decodedResponse['status'] == "success") { return decodedResponse.toString(); //Returning Response String } return decodedResponse["error"].toString(); } else { return "Error"; } } // 2. Build UI elements