1
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
- // Autogenerated from Pigeon (v3 .2.0 ), do not edit directly.
4
+ // Autogenerated from Pigeon (v9 .2.4 ), do not edit directly.
5
5
// See also: https://pub.dev/packages/pigeon
6
6
7
7
package io .flutter .plugins .pathprovider ;
14
14
import io .flutter .plugin .common .MessageCodec ;
15
15
import io .flutter .plugin .common .StandardMessageCodec ;
16
16
import java .util .ArrayList ;
17
- import java .util .HashMap ;
18
17
import java .util .List ;
19
- import java .util .Map ;
20
18
21
19
/** Generated class from Pigeon. */
22
- @ SuppressWarnings ({"unused" , "unchecked" , "CodeBlock2Expr" , "RedundantSuppression" })
20
+ @ SuppressWarnings ({"unused" , "unchecked" , "CodeBlock2Expr" , "RedundantSuppression" , "serial" })
23
21
public class Messages {
24
22
25
- public enum StorageDirectory {
26
- root (0 ),
27
- music (1 ),
28
- podcasts (2 ),
29
- ringtones (3 ),
30
- alarms (4 ),
31
- notifications (5 ),
32
- pictures (6 ),
33
- movies (7 ),
34
- downloads (8 ),
35
- dcim (9 ),
36
- documents (10 );
37
-
38
- private int index ;
23
+ /** Error class for passing custom error details to Flutter via a thrown PlatformException. */
24
+ public static class FlutterError extends RuntimeException {
39
25
40
- private StorageDirectory (final int index ) {
41
- this .index = index ;
26
+ /** The error code. */
27
+ public final String code ;
28
+
29
+ /** The error details. Must be a datatype supported by the api codec. */
30
+ public final Object details ;
31
+
32
+ public FlutterError (@ NonNull String code , @ Nullable String message , @ Nullable Object details ) {
33
+ super (message );
34
+ this .code = code ;
35
+ this .details = details ;
42
36
}
43
37
}
44
38
45
- private static class PathProviderApiCodec extends StandardMessageCodec {
46
- public static final PathProviderApiCodec INSTANCE = new PathProviderApiCodec ();
47
-
48
- private PathProviderApiCodec () {}
39
+ @ NonNull
40
+ protected static ArrayList <Object > wrapError (@ NonNull Throwable exception ) {
41
+ ArrayList <Object > errorList = new ArrayList <Object >(3 );
42
+ if (exception instanceof FlutterError ) {
43
+ FlutterError error = (FlutterError ) exception ;
44
+ errorList .add (error .code );
45
+ errorList .add (error .getMessage ());
46
+ errorList .add (error .details );
47
+ } else {
48
+ errorList .add (exception .toString ());
49
+ errorList .add (exception .getClass ().getSimpleName ());
50
+ errorList .add (
51
+ "Cause: " + exception .getCause () + ", Stacktrace: " + Log .getStackTraceString (exception ));
52
+ }
53
+ return errorList ;
49
54
}
50
55
56
+ public enum StorageDirectory {
57
+ ROOT (0 ),
58
+ MUSIC (1 ),
59
+ PODCASTS (2 ),
60
+ RINGTONES (3 ),
61
+ ALARMS (4 ),
62
+ NOTIFICATIONS (5 ),
63
+ PICTURES (6 ),
64
+ MOVIES (7 ),
65
+ DOWNLOADS (8 ),
66
+ DCIM (9 ),
67
+ DOCUMENTS (10 );
68
+
69
+ final int index ;
70
+
71
+ private StorageDirectory (final int index ) {
72
+ this .index = index ;
73
+ }
74
+ }
51
75
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
52
76
public interface PathProviderApi {
77
+
53
78
@ Nullable
54
79
String getTemporaryPath ();
55
80
@@ -69,14 +94,13 @@ public interface PathProviderApi {
69
94
List <String > getExternalStoragePaths (@ NonNull StorageDirectory directory );
70
95
71
96
/** The codec used by PathProviderApi. */
72
- static MessageCodec <Object > getCodec () {
73
- return PathProviderApiCodec . INSTANCE ;
97
+ static @ NonNull MessageCodec <Object > getCodec () {
98
+ return new StandardMessageCodec () ;
74
99
}
75
-
76
100
/**
77
101
* Sets up an instance of `PathProviderApi` to handle messages through the `binaryMessenger`.
78
102
*/
79
- static void setup (BinaryMessenger binaryMessenger , PathProviderApi api ) {
103
+ static void setup (@ NonNull BinaryMessenger binaryMessenger , @ Nullable PathProviderApi api ) {
80
104
{
81
105
BinaryMessenger .TaskQueue taskQueue = binaryMessenger .makeBackgroundTaskQueue ();
82
106
BasicMessageChannel <Object > channel =
@@ -88,12 +112,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
88
112
if (api != null ) {
89
113
channel .setMessageHandler (
90
114
(message , reply ) -> {
91
- Map < String , Object > wrapped = new HashMap < >();
115
+ ArrayList < Object > wrapped = new ArrayList < Object >();
92
116
try {
93
117
String output = api .getTemporaryPath ();
94
- wrapped .put ("result" , output );
95
- } catch (Error | RuntimeException exception ) {
96
- wrapped .put ("error" , wrapError (exception ));
118
+ wrapped .add (0 , output );
119
+ } catch (Throwable exception ) {
120
+ ArrayList <Object > wrappedError = wrapError (exception );
121
+ wrapped = wrappedError ;
97
122
}
98
123
reply .reply (wrapped );
99
124
});
@@ -112,12 +137,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
112
137
if (api != null ) {
113
138
channel .setMessageHandler (
114
139
(message , reply ) -> {
115
- Map < String , Object > wrapped = new HashMap < >();
140
+ ArrayList < Object > wrapped = new ArrayList < Object >();
116
141
try {
117
142
String output = api .getApplicationSupportPath ();
118
- wrapped .put ("result" , output );
119
- } catch (Error | RuntimeException exception ) {
120
- wrapped .put ("error" , wrapError (exception ));
143
+ wrapped .add (0 , output );
144
+ } catch (Throwable exception ) {
145
+ ArrayList <Object > wrappedError = wrapError (exception );
146
+ wrapped = wrappedError ;
121
147
}
122
148
reply .reply (wrapped );
123
149
});
@@ -136,12 +162,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
136
162
if (api != null ) {
137
163
channel .setMessageHandler (
138
164
(message , reply ) -> {
139
- Map < String , Object > wrapped = new HashMap < >();
165
+ ArrayList < Object > wrapped = new ArrayList < Object >();
140
166
try {
141
167
String output = api .getApplicationDocumentsPath ();
142
- wrapped .put ("result" , output );
143
- } catch (Error | RuntimeException exception ) {
144
- wrapped .put ("error" , wrapError (exception ));
168
+ wrapped .add (0 , output );
169
+ } catch (Throwable exception ) {
170
+ ArrayList <Object > wrappedError = wrapError (exception );
171
+ wrapped = wrappedError ;
145
172
}
146
173
reply .reply (wrapped );
147
174
});
@@ -160,12 +187,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
160
187
if (api != null ) {
161
188
channel .setMessageHandler (
162
189
(message , reply ) -> {
163
- Map < String , Object > wrapped = new HashMap < >();
190
+ ArrayList < Object > wrapped = new ArrayList < Object >();
164
191
try {
165
192
String output = api .getExternalStoragePath ();
166
- wrapped .put ("result" , output );
167
- } catch (Error | RuntimeException exception ) {
168
- wrapped .put ("error" , wrapError (exception ));
193
+ wrapped .add (0 , output );
194
+ } catch (Throwable exception ) {
195
+ ArrayList <Object > wrappedError = wrapError (exception );
196
+ wrapped = wrappedError ;
169
197
}
170
198
reply .reply (wrapped );
171
199
});
@@ -184,12 +212,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
184
212
if (api != null ) {
185
213
channel .setMessageHandler (
186
214
(message , reply ) -> {
187
- Map < String , Object > wrapped = new HashMap < >();
215
+ ArrayList < Object > wrapped = new ArrayList < Object >();
188
216
try {
189
217
List <String > output = api .getExternalCachePaths ();
190
- wrapped .put ("result" , output );
191
- } catch (Error | RuntimeException exception ) {
192
- wrapped .put ("error" , wrapError (exception ));
218
+ wrapped .add (0 , output );
219
+ } catch (Throwable exception ) {
220
+ ArrayList <Object > wrappedError = wrapError (exception );
221
+ wrapped = wrappedError ;
193
222
}
194
223
reply .reply (wrapped );
195
224
});
@@ -208,18 +237,16 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
208
237
if (api != null ) {
209
238
channel .setMessageHandler (
210
239
(message , reply ) -> {
211
- Map <String , Object > wrapped = new HashMap <>();
240
+ ArrayList <Object > wrapped = new ArrayList <Object >();
241
+ ArrayList <Object > args = (ArrayList <Object >) message ;
242
+ StorageDirectory directoryArg =
243
+ args .get (0 ) == null ? null : StorageDirectory .values ()[(int ) args .get (0 )];
212
244
try {
213
- ArrayList <Object > args = (ArrayList <Object >) message ;
214
- StorageDirectory directoryArg =
215
- args .get (0 ) == null ? null : StorageDirectory .values ()[(int ) args .get (0 )];
216
- if (directoryArg == null ) {
217
- throw new NullPointerException ("directoryArg unexpectedly null." );
218
- }
219
245
List <String > output = api .getExternalStoragePaths (directoryArg );
220
- wrapped .put ("result" , output );
221
- } catch (Error | RuntimeException exception ) {
222
- wrapped .put ("error" , wrapError (exception ));
246
+ wrapped .add (0 , output );
247
+ } catch (Throwable exception ) {
248
+ ArrayList <Object > wrappedError = wrapError (exception );
249
+ wrapped = wrappedError ;
223
250
}
224
251
reply .reply (wrapped );
225
252
});
@@ -229,14 +256,4 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
229
256
}
230
257
}
231
258
}
232
-
233
- private static Map <String , Object > wrapError (Throwable exception ) {
234
- Map <String , Object > errorMap = new HashMap <>();
235
- errorMap .put ("message" , exception .toString ());
236
- errorMap .put ("code" , exception .getClass ().getSimpleName ());
237
- errorMap .put (
238
- "details" ,
239
- "Cause: " + exception .getCause () + ", Stacktrace: " + Log .getStackTraceString (exception ));
240
- return errorMap ;
241
- }
242
259
}
0 commit comments