openFile method
Opens a file dialog for loading files and returns a file path.
Returns null
if the user cancels the operation.
Implementation
@override
Future<XFile?> openFile({
List<XTypeGroup>? acceptedTypeGroups,
String? initialDirectory,
String? confirmButtonText,
}) async {
final FileDialogResult result = await _hostApi.showOpenDialog(
SelectionOptions(
allowMultiple: false,
selectFolders: false,
allowedTypes: _typeGroupsFromXTypeGroups(acceptedTypeGroups),
),
initialDirectory,
confirmButtonText);
return result.paths.isEmpty ? null : XFile(result.paths.first!);
}