Seamless iCloud integration for your Flutter iOS apps!
iCloud_Storage_Sync simplifies iCloud storage integration, bringing powerful cloud capabilities to your Flutter iOS apps:
π Effortless backup and sync of app data
π±π» Consistent user experience across all devices
π Secure storage and retrieval of important information
βοΈ Seamless integration with the iCloud ecosystem
| Feature | Description |
|---|---|
| π | Get iCloud files |
| β¬οΈ | Upload files to iCloud |
| βοΈ | Rename iCloud files |
| ποΈ | Delete iCloud files |
| Move iCloud files | |
| π | Filter by path prefix |
| β±οΈ | Timeout support |
Advanced Features:
- π Path Filtering - Query specific subdirectories instead of entire container for better performance
- β±οΈ Timeout Support - Set time limits on metadata queries to prevent indefinite hangs
- π Progress Tracking - Monitor upload/download progress with callbacks
- π Stream Updates - Receive live updates as files change in iCloud
Add this to your pubspec.yaml:
dependencies:
icloud_storage_sync: ^1.0.0Run:
flutter pub getUpdate your iCloud Container ID in the example app:
In example/lib/controller/icloud_plugin_controller.dart:
final iCloudContainerId = 'iCloud.com.yourcompany.appname'; // Replace with your container IDIn example/ios/Runner/Info.plist:
<key>iCloud.com.yourcompany.appname</key> <!-- Replace with your container ID -->In example/ios/Runner/Runner.entitlements and RunnerDebug.entitlements:
<string>iCloud.com.yourcompany.appname</string> <!-- Replace with your container ID -->βΉοΈ Note: Your iCloud Container ID should match the format:
iCloud.<your-team-id>.<your-bundle-id>
Import in your Dart code:
import 'package:icloud_storage_sync/icloud_storage_sync.dart';Before diving in, make sure you have:
βοΈ An Apple Developer account
βοΈ App ID and iCloud Container ID
βοΈ iCloud capability enabled and assigned
βοΈ iCloud capability configured in Xcode
π See How to set up iCloud Container for step-by-step instructions.
Future<List<CloudFiles>> getCloudFiles({required String containerId}) async {
return await icloudSyncPlugin.getCloudFiles(containerId: containerId);
}// Gather files with optional path prefix filtering
Future<List<ICloudFile>> gatherFilesFromSubdirectory({
required String containerId,
required String pathPrefix,
}) async {
return await icloudSyncPlugin.gather(
containerId: containerId,
relativePathPrefix: pathPrefix, // e.g., 'Documents/', 'Projects/MyApp/'
);
}
// Gather files with timeout to prevent indefinite hangs
Future<List<ICloudFile>> gatherFilesWithTimeout({
required String containerId,
required Duration timeout,
}) async {
try {
return await icloudSyncPlugin.gather(
containerId: containerId,
timeout: timeout, // e.g., Duration(seconds: 30)
);
} on PlatformException catch (e) {
if (e.code == 'METADATA_QUERY_TIMEOUT') {
debugPrint('iCloud query timed out');
}
return [];
}
}
// Combine both features for optimal performance
Future<List<ICloudFile>> gatherFilesOptimized({
required String containerId,
required String pathPrefix,
}) async {
return await icloudSyncPlugin.gather(
containerId: containerId,
relativePathPrefix: pathPrefix,
timeout: Duration(seconds: 30),
);
}Features:
- π
relativePathPrefix- Filter to specific subdirectory for faster queries - β±οΈ
timeout- Set time limit to prevent indefinite hangs - π Both parameters are optional and backwards compatible
Future<void> upload({
required String containerId,
required String filePath,
String? destinationRelativePath,
StreamHandler<double>? onProgress,
}) async {
await icloudSyncPlugin.upload(
containerId: containerId,
filePath: filePath,
destinationRelativePath: destinationRelativePath,
onProgress: onProgress,
);
}Future<void> rename({
required String containerId,
required String relativePath,
required String newName,
}) async {
await icloudSyncPlugin.rename(
containerId: containerId,
relativePath: relativePath,
newName: newName,
);
}Future<void> delete({
required String containerId,
required String relativePath,
required bool isDirectory
}) async {
await icloudSyncPlugin.delete(
containerId: containerId,
relativePath: relativePath,
isDirectory: isDirectory
);
}Future replaceFile({
required String updatedFilePath,
required String relativePath
}) async {
await icloudSyncPlugin.replace(
containerId: iCloudContainerId,
updatedFilePath: updatedFilePath,
relativePath: relativePath,
);
}Future<void> move({
required String containerId,
required String fromRelativePath,
required String toRelativePath,
}) async {
await IcloudSyncPlatform.instance.move(
containerId: containerId,
fromRelativePath: fromRelativePath,
toRelativePath: toRelativePath,
);
}-
π€ Log in to your Apple Developer account and select 'Certificates, IDs & Profiles'.
-
π Create an App ID (if needed) and an iCloud Containers ID:
-
π Assign the iCloud Container to your App ID:
-
π» In Xcode, enable iCloud capability and select your container:
- Thanks to all the contributors who have helped shape this plugin
- Apple for providing the iCloud infrastructure
Made with β€οΈ by the DevCodeSpace

