@@ -14,37 +14,23 @@ class FirebaseApp {
1414 static final String defaultAppName =
1515 Platform .isIOS ? '__FIRAPP_DEFAULT' : '[DEFAULT]' ;
1616
17- @visibleForTesting
18- static const MethodChannel channel = MethodChannel (
19- 'plugins.flutter.io/firebase_core' ,
20- );
21-
2217 /// A copy of the options for this app. These are non-modifiable.
2318 ///
2419 /// This getter is asynchronous because apps can also be configured by native
2520 /// code.
2621 Future <FirebaseOptions > get options async {
27- final Map <String , dynamic > app =
28- await channel.invokeMapMethod <String , dynamic >(
29- 'FirebaseApp#appNamed' ,
30- name,
31- );
22+ final PlatformFirebaseApp app =
23+ await FirebaseCorePlatform .instance.appNamed (name);
3224 assert (app != null );
33- return FirebaseOptions . from ( app[ ' options' ]) ;
25+ return app. options;
3426 }
3527
3628 /// Returns a previously created FirebaseApp instance with the given name,
3729 /// or null if no such app exists.
3830 static Future <FirebaseApp > appNamed (String name) async {
39- // TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
40- // https://github.com/flutter/flutter/issues/26431
41- // ignore: strong_mode_implicit_dynamic_method
42- final Map <String , dynamic > app =
43- await channel.invokeMapMethod <String , dynamic >(
44- 'FirebaseApp#appNamed' ,
45- name,
46- );
47- return app == null ? null : FirebaseApp (name: app['name' ]);
31+ final PlatformFirebaseApp app =
32+ await FirebaseCorePlatform .instance.appNamed (name);
33+ return app == null ? null : FirebaseApp (name: app.name);
4834 }
4935
5036 /// Returns the default (first initialized) instance of the FirebaseApp.
@@ -69,22 +55,18 @@ class FirebaseApp {
6955 if (existingApp != null ) {
7056 return existingApp;
7157 }
72- await channel.invokeMethod <void >(
73- 'FirebaseApp#configure' ,
74- < String , dynamic > {'name' : name, 'options' : options.asMap},
75- );
58+ await FirebaseCorePlatform .instance.configure (name, options);
7659 return FirebaseApp (name: name);
7760 }
7861
7962 /// Returns a list of all extant FirebaseApp instances, or null if there are
8063 /// no FirebaseApp instances.
8164 static Future <List <FirebaseApp >> allApps () async {
82- final List <dynamic > result = await channel.invokeListMethod <dynamic >(
83- 'FirebaseApp#allApps' ,
84- );
65+ final List <PlatformFirebaseApp > result =
66+ await FirebaseCorePlatform .instance.allApps ();
8567 return result
8668 ? .map <FirebaseApp >(
87- (dynamic app) => FirebaseApp (name: app[ ' name' ] ),
69+ (PlatformFirebaseApp app) => FirebaseApp (name: app. name),
8870 )
8971 ? .toList ();
9072 }
0 commit comments