Conflict resolution
Nutrient Flutter SDK can detect external file changes on iOS. When external changes conflict with unsaved local changes, the SDK can resolve the conflict or ask the user to choose a resolution.
Configure conflict resolution
Set the fileConflictResolution option in IOSViewConfiguration to choose how the SDK handles file conflicts. Refer to the file conflict resolution(opens in a new tab) and iOS view configuration(opens in a new tab) API references for details.
NutrientDocumentView( documentPath: documentPath, configuration: const NutrientViewConfiguration( iosConfig: IOSViewConfiguration( fileConflictResolution: IOSFileConflictResolution.defaultBehavior, ), ),)Choose a conflict resolution option
Use one of the following conflict resolution options:
| Option | Description |
|---|---|
defaultBehavior | Shows an alert so the user can choose how to resolve the conflict. |
close | Closes the document when the SDK detects a conflict. |
save | Saves in-memory changes and overwrites external changes. Restores the file if deleted. |
reload | Discards local changes and reloads the document from disk. |
Save local changes when conflicts occur
The following example saves local changes when the SDK detects a conflict:
import 'package:flutter/material.dart';import 'package:nutrient_flutter/bindings.dart';
class DocumentViewer extends StatelessWidget { final String documentPath;
const DocumentViewer({super.key, required this.documentPath});
@override Widget build(BuildContext context) { return Scaffold( body: NutrientDocumentView( documentPath: documentPath, configuration: const NutrientViewConfiguration( iosConfig: IOSViewConfiguration( // Automatically save local changes when conflicts occur. fileConflictResolution: IOSFileConflictResolution.save, ), ), ), ); }}Check platform support
Nutrient Flutter SDK supports conflict resolution on iOS only:
| Platform | Support |
|---|---|
| iOS | Yes |
| Android | No |
| Web | No |
Conflict resolution relies on iOS file coordination APIs and Apple File System (APFS) copy-on-write functionality. On Android and web, the SDK doesn’t detect external file changes.