11// Copyright 2013 The Flutter Authors. All rights reserved.
22// Use of this source code is governed by a BSD-style license that can be
33// 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.
55// See also: https://pub.dev/packages/pigeon
66
77package io .flutter .plugins .pathprovider ;
1414import io .flutter .plugin .common .MessageCodec ;
1515import io .flutter .plugin .common .StandardMessageCodec ;
1616import java .util .ArrayList ;
17- import java .util .HashMap ;
1817import java .util .List ;
19- import java .util .Map ;
2018
2119/** Generated class from Pigeon. */
22- @ SuppressWarnings ({"unused" , "unchecked" , "CodeBlock2Expr" , "RedundantSuppression" })
20+ @ SuppressWarnings ({"unused" , "unchecked" , "CodeBlock2Expr" , "RedundantSuppression" , "serial" })
2321public class Messages {
2422
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 {
3925
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 ;
4236 }
4337 }
4438
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 ;
4954 }
5055
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+ }
5175 /** Generated interface from Pigeon that represents a handler of messages from Flutter. */
5276 public interface PathProviderApi {
77+
5378 @ Nullable
5479 String getTemporaryPath ();
5580
@@ -69,14 +94,13 @@ public interface PathProviderApi {
6994 List <String > getExternalStoragePaths (@ NonNull StorageDirectory directory );
7095
7196 /** The codec used by PathProviderApi. */
72- static MessageCodec <Object > getCodec () {
73- return PathProviderApiCodec . INSTANCE ;
97+ static @ NonNull MessageCodec <Object > getCodec () {
98+ return new StandardMessageCodec () ;
7499 }
75-
76100 /**
77101 * Sets up an instance of `PathProviderApi` to handle messages through the `binaryMessenger`.
78102 */
79- static void setup (BinaryMessenger binaryMessenger , PathProviderApi api ) {
103+ static void setup (@ NonNull BinaryMessenger binaryMessenger , @ Nullable PathProviderApi api ) {
80104 {
81105 BinaryMessenger .TaskQueue taskQueue = binaryMessenger .makeBackgroundTaskQueue ();
82106 BasicMessageChannel <Object > channel =
@@ -88,12 +112,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
88112 if (api != null ) {
89113 channel .setMessageHandler (
90114 (message , reply ) -> {
91- Map < String , Object > wrapped = new HashMap < >();
115+ ArrayList < Object > wrapped = new ArrayList < Object >();
92116 try {
93117 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 ;
97122 }
98123 reply .reply (wrapped );
99124 });
@@ -112,12 +137,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
112137 if (api != null ) {
113138 channel .setMessageHandler (
114139 (message , reply ) -> {
115- Map < String , Object > wrapped = new HashMap < >();
140+ ArrayList < Object > wrapped = new ArrayList < Object >();
116141 try {
117142 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 ;
121147 }
122148 reply .reply (wrapped );
123149 });
@@ -136,12 +162,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
136162 if (api != null ) {
137163 channel .setMessageHandler (
138164 (message , reply ) -> {
139- Map < String , Object > wrapped = new HashMap < >();
165+ ArrayList < Object > wrapped = new ArrayList < Object >();
140166 try {
141167 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 ;
145172 }
146173 reply .reply (wrapped );
147174 });
@@ -160,12 +187,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
160187 if (api != null ) {
161188 channel .setMessageHandler (
162189 (message , reply ) -> {
163- Map < String , Object > wrapped = new HashMap < >();
190+ ArrayList < Object > wrapped = new ArrayList < Object >();
164191 try {
165192 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 ;
169197 }
170198 reply .reply (wrapped );
171199 });
@@ -184,12 +212,13 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
184212 if (api != null ) {
185213 channel .setMessageHandler (
186214 (message , reply ) -> {
187- Map < String , Object > wrapped = new HashMap < >();
215+ ArrayList < Object > wrapped = new ArrayList < Object >();
188216 try {
189217 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 ;
193222 }
194223 reply .reply (wrapped );
195224 });
@@ -208,18 +237,16 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
208237 if (api != null ) {
209238 channel .setMessageHandler (
210239 (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 )];
212244 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- }
219245 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 ;
223250 }
224251 reply .reply (wrapped );
225252 });
@@ -229,14 +256,4 @@ static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) {
229256 }
230257 }
231258 }
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- }
242259}
0 commit comments