Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 01c234c

Browse files
committed
Migrated path_provider_ios to pigeon.
1 parent 395dc14 commit 01c234c

File tree

11 files changed

+451
-76
lines changed

11 files changed

+451
-76
lines changed

packages/path_provider/path_provider_ios/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.10
2+
3+
* Switches backend to pigeon.
4+
15
## 2.0.9
26

37
* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors

packages/path_provider/path_provider_ios/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 50;
6+
objectVersion = 46;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -512,6 +512,7 @@
512512
"$(PROJECT_DIR)/Flutter",
513513
);
514514
INFOPLIST_FILE = Runner/Info.plist;
515+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
515516
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
516517
LIBRARY_SEARCH_PATHS = (
517518
"$(inherited)",
@@ -533,6 +534,7 @@
533534
"$(PROJECT_DIR)/Flutter",
534535
);
535536
INFOPLIST_FILE = Runner/Info.plist;
537+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
536538
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
537539
LIBRARY_SEARCH_PATHS = (
538540
"$(inherited)",

packages/path_provider/path_provider_ios/ios/Classes/FLTPathProviderPlugin.m

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,41 @@
33
// found in the LICENSE file.
44

55
#import "FLTPathProviderPlugin.h"
6+
#import "messages.g.h"
67

7-
NSString *GetDirectoryOfType(NSSearchPathDirectory dir) {
8+
static NSString *GetDirectoryOfType(NSSearchPathDirectory dir) {
89
NSArray *paths = NSSearchPathForDirectoriesInDomains(dir, NSUserDomainMask, YES);
910
return paths.firstObject;
1011
}
1112

13+
@interface FLTPathProviderPlugin () <FLTPathProviderApi>
14+
@end
15+
1216
@implementation FLTPathProviderPlugin
1317

1418
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
15-
FlutterMethodChannel *channel =
16-
[FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/path_provider_ios"
17-
binaryMessenger:registrar.messenger];
18-
[channel setMethodCallHandler:^(FlutterMethodCall *call, FlutterResult result) {
19-
if ([@"getTemporaryDirectory" isEqualToString:call.method]) {
20-
result([self getTemporaryDirectory]);
21-
} else if ([@"getApplicationDocumentsDirectory" isEqualToString:call.method]) {
22-
result([self getApplicationDocumentsDirectory]);
23-
} else if ([@"getApplicationSupportDirectory" isEqualToString:call.method]) {
24-
result([self getApplicationSupportDirectory]);
25-
} else if ([@"getLibraryDirectory" isEqualToString:call.method]) {
26-
result([self getLibraryDirectory]);
27-
} else {
28-
result(FlutterMethodNotImplemented);
29-
}
30-
}];
31-
}
32-
33-
+ (NSString *)getTemporaryDirectory {
34-
return GetDirectoryOfType(NSCachesDirectory);
19+
FLTPathProviderPlugin *plugin = [[FLTPathProviderPlugin alloc] init];
20+
FLTPathProviderApiSetup(registrar.messenger, plugin);
3521
}
3622

37-
+ (NSString *)getApplicationDocumentsDirectory {
23+
- (nullable NSString *)getApplicationDocumentsPathWithError:
24+
(FlutterError *_Nullable __autoreleasing *_Nonnull)error {
3825
return GetDirectoryOfType(NSDocumentDirectory);
3926
}
4027

41-
+ (NSString *)getApplicationSupportDirectory {
28+
- (nullable NSString *)getApplicationSupportPathWithError:
29+
(FlutterError *_Nullable __autoreleasing *_Nonnull)error {
4230
return GetDirectoryOfType(NSApplicationSupportDirectory);
4331
}
4432

45-
+ (NSString *)getLibraryDirectory {
33+
- (nullable NSString *)getLibraryPathWithError:
34+
(FlutterError *_Nullable __autoreleasing *_Nonnull)error {
4635
return GetDirectoryOfType(NSLibraryDirectory);
4736
}
4837

38+
- (nullable NSString *)getTemporaryPathWithError:
39+
(FlutterError *_Nullable __autoreleasing *_Nonnull)error {
40+
return GetDirectoryOfType(NSCachesDirectory);
41+
}
42+
4943
@end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Autogenerated from Pigeon (v3.1.5), do not edit directly.
2+
// See also: https://pub.dev/packages/pigeon
3+
#import <Foundation/Foundation.h>
4+
@protocol FlutterBinaryMessenger;
5+
@protocol FlutterMessageCodec;
6+
@class FlutterError;
7+
@class FlutterStandardTypedData;
8+
9+
NS_ASSUME_NONNULL_BEGIN
10+
11+
/// The codec used by FLTPathProviderApi.
12+
NSObject<FlutterMessageCodec> *FLTPathProviderApiGetCodec(void);
13+
14+
@protocol FLTPathProviderApi
15+
- (nullable NSString *)getTemporaryPathWithError:(FlutterError *_Nullable *_Nonnull)error;
16+
- (nullable NSString *)getApplicationSupportPathWithError:(FlutterError *_Nullable *_Nonnull)error;
17+
- (nullable NSString *)getLibraryPathWithError:(FlutterError *_Nullable *_Nonnull)error;
18+
- (nullable NSString *)getApplicationDocumentsPathWithError:
19+
(FlutterError *_Nullable *_Nonnull)error;
20+
@end
21+
22+
extern void FLTPathProviderApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
23+
NSObject<FLTPathProviderApi> *_Nullable api);
24+
25+
NS_ASSUME_NONNULL_END
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// Autogenerated from Pigeon (v3.1.5), do not edit directly.
2+
// See also: https://pub.dev/packages/pigeon
3+
#import "messages.g.h"
4+
#import <Flutter/Flutter.h>
5+
6+
#if !__has_feature(objc_arc)
7+
#error File requires ARC to be enabled.
8+
#endif
9+
10+
static NSDictionary<NSString *, id> *wrapResult(id result, FlutterError *error) {
11+
NSDictionary *errorDict = (NSDictionary *)[NSNull null];
12+
if (error) {
13+
errorDict = @{
14+
@"code" : (error.code ?: [NSNull null]),
15+
@"message" : (error.message ?: [NSNull null]),
16+
@"details" : (error.details ?: [NSNull null]),
17+
};
18+
}
19+
return @{
20+
@"result" : (result ?: [NSNull null]),
21+
@"error" : errorDict,
22+
};
23+
}
24+
static id GetNullableObject(NSDictionary *dict, id key) {
25+
id result = dict[key];
26+
return (result == [NSNull null]) ? nil : result;
27+
}
28+
static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
29+
id result = array[key];
30+
return (result == [NSNull null]) ? nil : result;
31+
}
32+
33+
@interface FLTPathProviderApiCodecReader : FlutterStandardReader
34+
@end
35+
@implementation FLTPathProviderApiCodecReader
36+
@end
37+
38+
@interface FLTPathProviderApiCodecWriter : FlutterStandardWriter
39+
@end
40+
@implementation FLTPathProviderApiCodecWriter
41+
@end
42+
43+
@interface FLTPathProviderApiCodecReaderWriter : FlutterStandardReaderWriter
44+
@end
45+
@implementation FLTPathProviderApiCodecReaderWriter
46+
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
47+
return [[FLTPathProviderApiCodecWriter alloc] initWithData:data];
48+
}
49+
- (FlutterStandardReader *)readerWithData:(NSData *)data {
50+
return [[FLTPathProviderApiCodecReader alloc] initWithData:data];
51+
}
52+
@end
53+
54+
NSObject<FlutterMessageCodec> *FLTPathProviderApiGetCodec() {
55+
static dispatch_once_t sPred = 0;
56+
static FlutterStandardMessageCodec *sSharedObject = nil;
57+
dispatch_once(&sPred, ^{
58+
FLTPathProviderApiCodecReaderWriter *readerWriter =
59+
[[FLTPathProviderApiCodecReaderWriter alloc] init];
60+
sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
61+
});
62+
return sSharedObject;
63+
}
64+
65+
void FLTPathProviderApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
66+
NSObject<FLTPathProviderApi> *api) {
67+
{
68+
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
69+
initWithName:@"dev.flutter.pigeon.PathProviderApi.getTemporaryPath"
70+
binaryMessenger:binaryMessenger
71+
codec:FLTPathProviderApiGetCodec()];
72+
if (api) {
73+
NSCAssert(
74+
[api respondsToSelector:@selector(getTemporaryPathWithError:)],
75+
@"FLTPathProviderApi api (%@) doesn't respond to @selector(getTemporaryPathWithError:)",
76+
api);
77+
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
78+
FlutterError *error;
79+
NSString *output = [api getTemporaryPathWithError:&error];
80+
callback(wrapResult(output, error));
81+
}];
82+
} else {
83+
[channel setMessageHandler:nil];
84+
}
85+
}
86+
{
87+
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
88+
initWithName:@"dev.flutter.pigeon.PathProviderApi.getApplicationSupportPath"
89+
binaryMessenger:binaryMessenger
90+
codec:FLTPathProviderApiGetCodec()];
91+
if (api) {
92+
NSCAssert([api respondsToSelector:@selector(getApplicationSupportPathWithError:)],
93+
@"FLTPathProviderApi api (%@) doesn't respond to "
94+
@"@selector(getApplicationSupportPathWithError:)",
95+
api);
96+
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
97+
FlutterError *error;
98+
NSString *output = [api getApplicationSupportPathWithError:&error];
99+
callback(wrapResult(output, error));
100+
}];
101+
} else {
102+
[channel setMessageHandler:nil];
103+
}
104+
}
105+
{
106+
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
107+
initWithName:@"dev.flutter.pigeon.PathProviderApi.getLibraryPath"
108+
binaryMessenger:binaryMessenger
109+
codec:FLTPathProviderApiGetCodec()];
110+
if (api) {
111+
NSCAssert(
112+
[api respondsToSelector:@selector(getLibraryPathWithError:)],
113+
@"FLTPathProviderApi api (%@) doesn't respond to @selector(getLibraryPathWithError:)",
114+
api);
115+
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
116+
FlutterError *error;
117+
NSString *output = [api getLibraryPathWithError:&error];
118+
callback(wrapResult(output, error));
119+
}];
120+
} else {
121+
[channel setMessageHandler:nil];
122+
}
123+
}
124+
{
125+
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
126+
initWithName:@"dev.flutter.pigeon.PathProviderApi.getApplicationDocumentsPath"
127+
binaryMessenger:binaryMessenger
128+
codec:FLTPathProviderApiGetCodec()];
129+
if (api) {
130+
NSCAssert([api respondsToSelector:@selector(getApplicationDocumentsPathWithError:)],
131+
@"FLTPathProviderApi api (%@) doesn't respond to "
132+
@"@selector(getApplicationDocumentsPathWithError:)",
133+
api);
134+
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
135+
FlutterError *error;
136+
NSString *output = [api getApplicationDocumentsPathWithError:&error];
137+
callback(wrapResult(output, error));
138+
}];
139+
} else {
140+
[channel setMessageHandler:nil];
141+
}
142+
}
143+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// Autogenerated from Pigeon (v3.1.5), do not edit directly.
2+
// See also: https://pub.dev/packages/pigeon
3+
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name
4+
// @dart = 2.12
5+
import 'dart:async';
6+
import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
7+
8+
import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer;
9+
import 'package:flutter/services.dart';
10+
11+
class _PathProviderApiCodec extends StandardMessageCodec {
12+
const _PathProviderApiCodec();
13+
}
14+
15+
class PathProviderApi {
16+
/// Constructor for [PathProviderApi]. The [binaryMessenger] named argument is
17+
/// available for dependency injection. If it is left null, the default
18+
/// BinaryMessenger will be used which routes to the host platform.
19+
PathProviderApi({BinaryMessenger? binaryMessenger})
20+
: _binaryMessenger = binaryMessenger;
21+
22+
final BinaryMessenger? _binaryMessenger;
23+
24+
static const MessageCodec<Object?> codec = _PathProviderApiCodec();
25+
26+
Future<String?> getTemporaryPath() async {
27+
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
28+
'dev.flutter.pigeon.PathProviderApi.getTemporaryPath', codec,
29+
binaryMessenger: _binaryMessenger);
30+
final Map<Object?, Object?>? replyMap =
31+
await channel.send(null) as Map<Object?, Object?>?;
32+
if (replyMap == null) {
33+
throw PlatformException(
34+
code: 'channel-error',
35+
message: 'Unable to establish connection on channel.',
36+
);
37+
} else if (replyMap['error'] != null) {
38+
final Map<Object?, Object?> error =
39+
(replyMap['error'] as Map<Object?, Object?>?)!;
40+
throw PlatformException(
41+
code: (error['code'] as String?)!,
42+
message: error['message'] as String?,
43+
details: error['details'],
44+
);
45+
} else {
46+
return (replyMap['result'] as String?);
47+
}
48+
}
49+
50+
Future<String?> getApplicationSupportPath() async {
51+
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
52+
'dev.flutter.pigeon.PathProviderApi.getApplicationSupportPath', codec,
53+
binaryMessenger: _binaryMessenger);
54+
final Map<Object?, Object?>? replyMap =
55+
await channel.send(null) as Map<Object?, Object?>?;
56+
if (replyMap == null) {
57+
throw PlatformException(
58+
code: 'channel-error',
59+
message: 'Unable to establish connection on channel.',
60+
);
61+
} else if (replyMap['error'] != null) {
62+
final Map<Object?, Object?> error =
63+
(replyMap['error'] as Map<Object?, Object?>?)!;
64+
throw PlatformException(
65+
code: (error['code'] as String?)!,
66+
message: error['message'] as String?,
67+
details: error['details'],
68+
);
69+
} else {
70+
return (replyMap['result'] as String?);
71+
}
72+
}
73+
74+
Future<String?> getLibraryPath() async {
75+
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
76+
'dev.flutter.pigeon.PathProviderApi.getLibraryPath', codec,
77+
binaryMessenger: _binaryMessenger);
78+
final Map<Object?, Object?>? replyMap =
79+
await channel.send(null) as Map<Object?, Object?>?;
80+
if (replyMap == null) {
81+
throw PlatformException(
82+
code: 'channel-error',
83+
message: 'Unable to establish connection on channel.',
84+
);
85+
} else if (replyMap['error'] != null) {
86+
final Map<Object?, Object?> error =
87+
(replyMap['error'] as Map<Object?, Object?>?)!;
88+
throw PlatformException(
89+
code: (error['code'] as String?)!,
90+
message: error['message'] as String?,
91+
details: error['details'],
92+
);
93+
} else {
94+
return (replyMap['result'] as String?);
95+
}
96+
}
97+
98+
Future<String?> getApplicationDocumentsPath() async {
99+
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
100+
'dev.flutter.pigeon.PathProviderApi.getApplicationDocumentsPath', codec,
101+
binaryMessenger: _binaryMessenger);
102+
final Map<Object?, Object?>? replyMap =
103+
await channel.send(null) as Map<Object?, Object?>?;
104+
if (replyMap == null) {
105+
throw PlatformException(
106+
code: 'channel-error',
107+
message: 'Unable to establish connection on channel.',
108+
);
109+
} else if (replyMap['error'] != null) {
110+
final Map<Object?, Object?> error =
111+
(replyMap['error'] as Map<Object?, Object?>?)!;
112+
throw PlatformException(
113+
code: (error['code'] as String?)!,
114+
message: error['message'] as String?,
115+
details: error['details'],
116+
);
117+
} else {
118+
return (replyMap['result'] as String?);
119+
}
120+
}
121+
}

0 commit comments

Comments
 (0)