@@ -14,37 +14,23 @@ class FirebaseApp {
14
14
static final String defaultAppName =
15
15
Platform .isIOS ? '__FIRAPP_DEFAULT' : '[DEFAULT]' ;
16
16
17
- @visibleForTesting
18
- static const MethodChannel channel = MethodChannel (
19
- 'plugins.flutter.io/firebase_core' ,
20
- );
21
-
22
17
/// A copy of the options for this app. These are non-modifiable.
23
18
///
24
19
/// This getter is asynchronous because apps can also be configured by native
25
20
/// code.
26
21
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);
32
24
assert (app != null );
33
- return FirebaseOptions . from ( app[ ' options' ]) ;
25
+ return app. options;
34
26
}
35
27
36
28
/// Returns a previously created FirebaseApp instance with the given name,
37
29
/// or null if no such app exists.
38
30
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);
48
34
}
49
35
50
36
/// Returns the default (first initialized) instance of the FirebaseApp.
@@ -69,22 +55,18 @@ class FirebaseApp {
69
55
if (existingApp != null ) {
70
56
return existingApp;
71
57
}
72
- await channel.invokeMethod <void >(
73
- 'FirebaseApp#configure' ,
74
- < String , dynamic > {'name' : name, 'options' : options.asMap},
75
- );
58
+ await FirebaseCorePlatform .instance.configure (name, options);
76
59
return FirebaseApp (name: name);
77
60
}
78
61
79
62
/// Returns a list of all extant FirebaseApp instances, or null if there are
80
63
/// no FirebaseApp instances.
81
64
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 ();
85
67
return result
86
68
? .map <FirebaseApp >(
87
- (dynamic app) => FirebaseApp (name: app[ ' name' ] ),
69
+ (PlatformFirebaseApp app) => FirebaseApp (name: app. name),
88
70
)
89
71
? .toList ();
90
72
}
0 commit comments