Skip to content

Commit

Permalink
Merge pull request #1494 from Aulig/master
Browse files Browse the repository at this point in the history
Compile out broken references if PICKER_DOCUMENT is set to false
  • Loading branch information
navaronbracke authored Apr 18, 2024
2 parents 05af933 + d82480f commit 0fb60c9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 8.0.1
### iOS
Fixes an issue preventing compilation on iOS when using Pod::PICKER_DOCUMENT = false.

## 8.0.0+1
Removes linter warnings and fixes CI/CD.

Expand Down
8 changes: 8 additions & 0 deletions ios/Classes/FilePickerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,17 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
details:nil]);
#endif
} else if([call.method isEqualToString:@"save"]) {
#ifdef PICKER_DOCUMENT
NSString *fileName = [arguments valueForKey:@"fileName"];
NSString *fileType = [arguments valueForKey:@"fileType"];
NSString *initialDirectory = [arguments valueForKey:@"initialDirectory"];
FlutterStandardTypedData *bytes = [arguments valueForKey:@"bytes"];
[self saveFileWithName:fileName fileType:fileType initialDirectory:initialDirectory bytes: bytes];
#else
_result([FlutterError errorWithCode:@"Unsupported function"
message:@"The save function requires the document picker to be compiled in. Remove the Pod::PICKER_DOCUMENT=false statement from your Podfile."
details:nil]);
#endif
} else {
result(FlutterMethodNotImplemented);
_result = nil;
Expand All @@ -167,6 +173,7 @@ - (NSString*)getDocumentDirectory {

#pragma mark - Resolvers

#ifdef PICKER_DOCUMENT
- (void)saveFileWithName:(NSString*)fileName fileType:(NSString *)fileType initialDirectory:(NSString*)initialDirectory bytes:(FlutterStandardTypedData*)bytes{
self.isSaveFile = YES;
NSFileManager* fm = [NSFileManager defaultManager];
Expand Down Expand Up @@ -197,6 +204,7 @@ - (void)saveFileWithName:(NSString*)fileName fileType:(NSString *)fileType initi
}
[[self viewControllerWithWindow:nil] presentViewController:self.documentPickerController animated:YES completion:nil];
}
#endif // PICKER_DOCUMENT

#ifdef PICKER_DOCUMENT
- (void)resolvePickDocumentWithMultiPick:(BOOL)allowsMultipleSelection pickDirectory:(BOOL)isDirectory {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A package that allows you to use a native file explorer to pick sin
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
repository: https://github.com/miguelpruivo/flutter_file_picker
issue_tracker: https://github.com/miguelpruivo/flutter_file_picker/issues
version: 8.0.0+1
version: 8.0.1

dependencies:
flutter:
Expand Down

0 comments on commit 0fb60c9

Please sign in to comment.