Skip to content

Commit 9c8e843

Browse files
fix: 'Null' is not a subtype of type 'String' in type cast on Linux (#405)
Co-authored-by: Russell Wheatley <russellwheatley85@gmail.com>
1 parent 131555f commit 9c8e843

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

packages/flutterfire_cli/lib/src/firebase.dart

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Future<String?> getDefaultFirebaseProjectId() async {
5050
final fileContents = firebaseRcFile.readAsStringSync();
5151
try {
5252
final jsonMap =
53-
const JsonDecoder().convert(fileContents) as Map<String, dynamic>;
53+
const JsonDecoder().convert(fileContents) as Map<String, dynamic>;
5454
if (jsonMap['projects'] != null &&
5555
(jsonMap['projects'] as Map)['default'] != null) {
5656
return (jsonMap['projects'] as Map)['default'] as String;
@@ -67,11 +67,11 @@ Future<String?> getDefaultFirebaseProjectId() async {
6767
/// final result = await runFirebaseCommand(['projects:list']);
6868
/// print(result);
6969
Future<Map<String, dynamic>> runFirebaseCommand(
70-
List<String> commandAndArgs, {
71-
String? project,
72-
String? account,
73-
String? serviceAccount,
74-
}) async {
70+
List<String> commandAndArgs, {
71+
String? project,
72+
String? account,
73+
String? serviceAccount,
74+
}) async {
7575
final cliExists = await exists();
7676
if (!cliExists) {
7777
throw FirebaseCommandException(
@@ -116,7 +116,7 @@ Future<Map<String, dynamic>> runFirebaseCommand(
116116
if (jsonString.length > characterLimit) {
117117
// If the JSON string is large, write it to a temporary file
118118
final tempFile =
119-
File('${Directory.systemTemp.path}/firebase_output.json');
119+
File('${Directory.systemTemp.path}/firebase_output.json');
120120
await tempFile.writeAsString(jsonString);
121121

122122
// Read from the temporary file to create a Dart object
@@ -141,14 +141,14 @@ Future<Map<String, dynamic>> runFirebaseCommand(
141141
rethrow;
142142
}
143143

144-
if (process.exitCode > 0 || commandResult['status'] == 'error') {
145-
throw FirebaseCommandException(
146-
execArgs.join(' '),
147-
commandResult['error'] as String,
148-
);
144+
if (commandResult['status'] == 'success') {
145+
return commandResult;
149146
}
150147

151-
return commandResult;
148+
throw FirebaseCommandException(
149+
execArgs.join(' '),
150+
commandResult['error'] as String,
151+
);
152152
}
153153

154154
/// Get all available Firebase projects for the authenticated CLI user
@@ -171,8 +171,8 @@ Future<List<FirebaseProject>> getProjects({
171171
return result
172172
.map<FirebaseProject>(
173173
(Map<String, dynamic> e) =>
174-
FirebaseProject.fromJson(Map<String, dynamic>.from(e)),
175-
)
174+
FirebaseProject.fromJson(Map<String, dynamic>.from(e)),
175+
)
176176
.where((project) => project.state == 'ACTIVE')
177177
.toList();
178178
} catch (e) {
@@ -231,8 +231,8 @@ Future<List<FirebaseApp>> getApps({
231231
return result
232232
.map<FirebaseApp>(
233233
(Map<String, dynamic> e) =>
234-
FirebaseApp.fromJson(Map<String, dynamic>.from(e)),
235-
)
234+
FirebaseApp.fromJson(Map<String, dynamic>.from(e)),
235+
)
236236
.toList();
237237
}
238238

@@ -300,7 +300,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
300300

301301
_assertFirebaseSupportedPlatform(platformFirebase);
302302
final fetchingAppsSpinner = spinner(
303-
(done) {
303+
(done) {
304304
final loggingAppName =
305305
packageNameOrBundleIdentifier ?? webAppId ?? displayNameWithPlatform;
306306
if (!done) {
@@ -333,7 +333,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
333333
final flagOption = platform == kWeb ? kWebAppIdFlag : kWindowsAppIdFlag;
334334
// Find provided web app id for web and windows, otherwise, throw Exception that it doesn't exist
335335
final webApp = unfilteredFirebaseApps.firstWhere(
336-
(firebaseApp) => firebaseApp.appId == webAppId,
336+
(firebaseApp) => firebaseApp.appId == webAppId,
337337
orElse: () {
338338
fetchingAppsSpinner.done();
339339
throw Exception(
@@ -347,7 +347,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
347347
}
348348
// Find web app for web and windows using display name with this signature: "flutter_app_name (platform)
349349
filteredFirebaseApps = unfilteredFirebaseApps.where(
350-
(firebaseApp) {
350+
(firebaseApp) {
351351
if (firebaseApp.displayName == displayNameWithPlatform) {
352352
return true;
353353
}
@@ -357,17 +357,17 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
357357
// Find any for that platform if no web app found with display name
358358
if (filteredFirebaseApps.isEmpty) {
359359
filteredFirebaseApps = unfilteredFirebaseApps.where(
360-
(firebaseApp) {
360+
(firebaseApp) {
361361
return firebaseApp.platform == platform;
362362
},
363363
);
364364
}
365365
} else {
366366
filteredFirebaseApps = unfilteredFirebaseApps.where(
367-
(firebaseApp) {
367+
(firebaseApp) {
368368
if (packageNameOrBundleIdentifier != null) {
369369
return firebaseApp.packageNameOrBundleIdentifier ==
370-
packageNameOrBundleIdentifier &&
370+
packageNameOrBundleIdentifier &&
371371
firebaseApp.platform == platformFirebase;
372372
}
373373
return false;
@@ -405,7 +405,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
405405
);
406406
break;
407407
case kWeb:
408-
// This is used to also create windows app, Firebase has no concept of a windows app
408+
// This is used to also create windows app, Firebase has no concept of a windows app
409409
createFirebaseAppFuture = createWebApp(
410410
project: project,
411411
displayName: displayNameWithPlatform,
@@ -419,7 +419,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
419419
}
420420

421421
final creatingAppSpinner = spinner(
422-
(done) {
422+
(done) {
423423
if (!done) {
424424
return AnsiStyles.bold(
425425
'Registering new Firebase ${AnsiStyles.cyan(platform)} app on Firebase project ${AnsiStyles.cyan(project)}.',
@@ -519,7 +519,7 @@ Future<String> getAccessToken() async {
519519
: Platform.environment['HOME']!;
520520
// Path to 'firebase-tools.json'
521521
final configPath =
522-
path.join(homeDir, '.config', 'configstore', 'firebase-tools.json');
522+
path.join(homeDir, '.config', 'configstore', 'firebase-tools.json');
523523
final configFile = File(configPath);
524524
if (!configFile.existsSync()) {
525525
throw Exception(
@@ -536,7 +536,7 @@ Future<String> getAccessToken() async {
536536
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
537537
// Values for obtaining the access token are taken from the Firebase CLI source code: https://github.com/firebase/firebase-tools/blob/b14b5f38fe23da6543778a588811b0e2391427c0/src/api.ts#L18
538538
body:
539-
'grant_type=refresh_token&client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&client_secret=j9iVZfS8kkCEFUPaAeJV0sAi&refresh_token=$refreshToken',
539+
'grant_type=refresh_token&client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&client_secret=j9iVZfS8kkCEFUPaAeJV0sAi&refresh_token=$refreshToken',
540540
);
541541

542542
if (response.statusCode == 200) {
@@ -551,19 +551,19 @@ Future<String> getAccessToken() async {
551551

552552
// Return string value of "GoogleService-Info.plist" or "google-services.json" file for relevant platform
553553
Future<String> getServiceFileContent(
554-
String projectId,
555-
String appId,
556-
String accessToken,
557-
String platform,
558-
) async {
554+
String projectId,
555+
String appId,
556+
String accessToken,
557+
String platform,
558+
) async {
559559
String? uri;
560560

561561
if (platform == kIos || platform == kMacos) {
562562
uri =
563-
'https://firebase.googleapis.com/v1beta1/projects/$projectId/iosApps/$appId/config';
563+
'https://firebase.googleapis.com/v1beta1/projects/$projectId/iosApps/$appId/config';
564564
} else if (platform == kAndroid) {
565565
uri =
566-
'https://firebase.googleapis.com/v1beta1/projects/$projectId/androidApps/$appId/config';
566+
'https://firebase.googleapis.com/v1beta1/projects/$projectId/androidApps/$appId/config';
567567
} else {
568568
throw ServiceFileException(
569569
platform,

0 commit comments

Comments
 (0)