generate static method
Implementation
static String generate(List<String> modules) {
final hasAuth = modules.contains('auth');
final hasFirestore = modules.contains('firestore');
final hasStorage = modules.contains('storage');
final hasFCM = modules.contains('fcm');
return '''
import 'dart:typed_data';
import 'package:firebase_core/firebase_core.dart';
${hasAuth ? "import 'package:firebase_auth/firebase_auth.dart';" : ''}
${hasFirestore ? "import 'package:cloud_firestore/cloud_firestore.dart';" : ''}
${hasStorage ? "import 'package:firebase_storage/firebase_storage.dart';" : ''}
${hasFCM ? "import 'package:firebase_messaging/firebase_messaging.dart';" : ''}
import 'dart:io';
/// Firebase Operations Service
/// Handles all Firebase CRUD operations for the app
class FirebaseOperations {
${hasAuth ? _generateAuthOperations() : ''}
${hasFirestore ? _generateFirestoreOperations() : ''}
${hasStorage ? _generateStorageOperations() : ''}
${hasFCM ? _generateFCMOperations() : ''}
}
// Custom Exception Classes
class FirebaseOperationException implements Exception {
final String message;
final String? code;
FirebaseOperationException(this.message, {this.code});
@override
String toString() => 'FirebaseOperationException: \$message (Code: \$code)';
}
''';
}