custom action is returning "error: An unexpected error occurred - Unsupported operation: _Namespace"

Custom Code

I am trying to decode base64 string into audio data, the action decodes the string and returns the path to the mp3 file but when the action tries to write the audio data into the mp3 file is keep getting an error.

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 'dart:convert';
import 'dart:io';

Future<String> newCustomAction(String? base64Data) async {
  // Accept Base64 string, decode it, and return the audio file path
  if (base64Data == null || base64Data.isEmpty) {
    return "Invalid base64 data";
  }

  try {
    // Decode Base64 string
    List<int> bytes;
    try {
      bytes = base64.decode(base64Data);
    } catch (e) {
      return "Error: Failed to decode Base64 - ${e.toString()}";
    }

    // Generate a unique file name for the audio file as MP3
    String fileName = 'audio_${DateTime.now().millisecondsSinceEpoch}.mp3';

    // Create the file (without specifying any directory)
    File file = File(fileName);

    // Write bytes to the file
    await file.writeAsBytes(bytes);

    // Return the file name as the result (note: file will be saved in the app's current working directory)
    return fileName;
  } catch (e) {
    return "Error: An unexpected error occurred - ${e.toString()}";
  }
}
What have you tried so far?

Getting this "error: An unexpected error occurred - Unsupported operation: _Namespace" every time I trying running the action

Did you check FlutterFlow's Documentation for this topic?
No
1
2 replies