Can you call a Custom Action from Another Custom Action??

Custom Code
  • I want to create a custom action for logging errors generated by Custom Actions & Functions in my SAAS App.

  • I want to import 'package:flutter/foundation.dart'; , to do this i cannot create a custom Function

  • The only way i can import foundation.dart is in a custom action

  • Can you call a Custom Action from Another Custom Action??

  • Below is code

import 'package:cloud_firestore/cloud_firestore.dart';

import 'package:firebase_analytics/firebase_analytics.dart';

import 'package:flutter/foundation.dart';

Future<void> logError(

String lemonCustomerId,

String errorMessage,

) async {

// Log error to the console

if (kDebugMode) {

print('Error for customer $lemonCustomerId: $errorMessage');

}

// Log error to Firestore

await FirebaseFirestore.instance.collection('error_logs').add({

'lemon_customer_id': lemonCustomerId,

'error_message': errorMessage,

'timestamp': FieldValue.serverTimestamp(),

});

// Optionally log error to analytics

await FirebaseAnalytics.instance.logEvent(

name: 'subscription_error',

parameters: {

'lemon_customer_id': lemonCustomerId,

'error_message': errorMessage,

},

);

}

Future<dynamic> updateSubscriptionButtonsText(

String lemonCustomerId,

String varientTrialDetailsCollectionName,

String subscriptionsCollectionName,

String userCollectionName,

List<String> variantIdAppStateList,

String varientTrialDetailsDocName,

) async {

try {

// Your existing code...

if (subscriptionQuerySnapshot.docs.isEmpty) {

final errorMessage =

'No subscriptions found for the given lemon_customer_id';

await logError(lemonCustomerId, errorMessage);

return;

}

if (lemonSubscriptionId == -1) {

final errorMessage = 'Invalid subscription with lemon_subscription_id -1';

await logError(lemonCustomerId, errorMessage);

return;

}

if (!trialDetailsDoc.exists) {

final errorMessage =

'No variant trial details found for the given document name';

await logError(lemonCustomerId, errorMessage);

return;

}

if (userDocSnapshot.docs.isEmpty) {

final errorMessage = 'No user found for the given lemon_customer_id';

await logError(lemonCustomerId, errorMessage);

return;

}

// Your existing code...

final successMessage =

'Subscription buttons updated based on trial and subscription conditions';

await logError(lemonCustomerId, successMessage);

} catch (e) {

final errorMessage = 'Error updating subscription buttons: $e';

await logError(lemonCustomerId, errorMessage);

}

}

What have you tried so far?

nothing

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