firebase_backup_restore
A flutter plugin for backup and restoring firebase cloud documents.
Register with firebase
-
add firebase_core and cloud_firestore dependencies.
-
for android - Add google-services.json to your android/app folder.
-
for ios - Add GoogleService-info.plist to your ios/Runner folder.
-
Initialize firebase
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
Installation
- Pub get
firebase_backup_restore: ^0.0.1
- Import
import 'package:firebase_backup_restore/results.dart';
import 'package:firebase_backup_restore/firebase_backup_restore.dart';
- Initialize firestore collection list
FirebaseBackupRestore().collections = ['posts', 'users'];
Using
- Backup All
await FirebaseBackupRestore().backupAll();
- Restore All
await FirebaseBackupRestore().restoreAll();
- Backup specific document
await FirebaseBackupRestore().backup(collectionId: "users");
- Restore specific document
await FirebaseBackupRestore().restore(collectionId: "users");