Skip to content

fix: 'Null' is not a subtype of type 'String' in type cast on Linux #405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions packages/flutterfire_cli/lib/src/firebase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Future<String?> getDefaultFirebaseProjectId() async {
final fileContents = firebaseRcFile.readAsStringSync();
try {
final jsonMap =
const JsonDecoder().convert(fileContents) as Map<String, dynamic>;
const JsonDecoder().convert(fileContents) as Map<String, dynamic>;
if (jsonMap['projects'] != null &&
(jsonMap['projects'] as Map)['default'] != null) {
return (jsonMap['projects'] as Map)['default'] as String;
Expand All @@ -67,11 +67,11 @@ Future<String?> getDefaultFirebaseProjectId() async {
/// final result = await runFirebaseCommand(['projects:list']);
/// print(result);
Future<Map<String, dynamic>> runFirebaseCommand(
List<String> commandAndArgs, {
String? project,
String? account,
String? serviceAccount,
}) async {
List<String> commandAndArgs, {
String? project,
String? account,
String? serviceAccount,
}) async {
final cliExists = await exists();
if (!cliExists) {
throw FirebaseCommandException(
Expand Down Expand Up @@ -116,7 +116,7 @@ Future<Map<String, dynamic>> runFirebaseCommand(
if (jsonString.length > characterLimit) {
// If the JSON string is large, write it to a temporary file
final tempFile =
File('${Directory.systemTemp.path}/firebase_output.json');
File('${Directory.systemTemp.path}/firebase_output.json');
await tempFile.writeAsString(jsonString);

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

if (process.exitCode > 0 || commandResult['status'] == 'error') {
throw FirebaseCommandException(
execArgs.join(' '),
commandResult['error'] as String,
);
if (commandResult['status'] == 'success') {
return commandResult;
}

return commandResult;
throw FirebaseCommandException(
execArgs.join(' '),
commandResult['error'] as String,
);
}

/// Get all available Firebase projects for the authenticated CLI user
Expand All @@ -171,8 +171,8 @@ Future<List<FirebaseProject>> getProjects({
return result
.map<FirebaseProject>(
(Map<String, dynamic> e) =>
FirebaseProject.fromJson(Map<String, dynamic>.from(e)),
)
FirebaseProject.fromJson(Map<String, dynamic>.from(e)),
)
.where((project) => project.state == 'ACTIVE')
.toList();
} catch (e) {
Expand Down Expand Up @@ -231,8 +231,8 @@ Future<List<FirebaseApp>> getApps({
return result
.map<FirebaseApp>(
(Map<String, dynamic> e) =>
FirebaseApp.fromJson(Map<String, dynamic>.from(e)),
)
FirebaseApp.fromJson(Map<String, dynamic>.from(e)),
)
.toList();
}

Expand Down Expand Up @@ -300,7 +300,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({

_assertFirebaseSupportedPlatform(platformFirebase);
final fetchingAppsSpinner = spinner(
(done) {
(done) {
final loggingAppName =
packageNameOrBundleIdentifier ?? webAppId ?? displayNameWithPlatform;
if (!done) {
Expand Down Expand Up @@ -333,7 +333,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
final flagOption = platform == kWeb ? kWebAppIdFlag : kWindowsAppIdFlag;
// Find provided web app id for web and windows, otherwise, throw Exception that it doesn't exist
final webApp = unfilteredFirebaseApps.firstWhere(
(firebaseApp) => firebaseApp.appId == webAppId,
(firebaseApp) => firebaseApp.appId == webAppId,
orElse: () {
fetchingAppsSpinner.done();
throw Exception(
Expand All @@ -347,7 +347,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
}
// Find web app for web and windows using display name with this signature: "flutter_app_name (platform)
filteredFirebaseApps = unfilteredFirebaseApps.where(
(firebaseApp) {
(firebaseApp) {
if (firebaseApp.displayName == displayNameWithPlatform) {
return true;
}
Expand All @@ -357,17 +357,17 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
// Find any for that platform if no web app found with display name
if (filteredFirebaseApps.isEmpty) {
filteredFirebaseApps = unfilteredFirebaseApps.where(
(firebaseApp) {
(firebaseApp) {
return firebaseApp.platform == platform;
},
);
}
} else {
filteredFirebaseApps = unfilteredFirebaseApps.where(
(firebaseApp) {
(firebaseApp) {
if (packageNameOrBundleIdentifier != null) {
return firebaseApp.packageNameOrBundleIdentifier ==
packageNameOrBundleIdentifier &&
packageNameOrBundleIdentifier &&
firebaseApp.platform == platformFirebase;
}
return false;
Expand Down Expand Up @@ -405,7 +405,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
);
break;
case kWeb:
// This is used to also create windows app, Firebase has no concept of a windows app
// This is used to also create windows app, Firebase has no concept of a windows app
createFirebaseAppFuture = createWebApp(
project: project,
displayName: displayNameWithPlatform,
Expand All @@ -419,7 +419,7 @@ Future<FirebaseApp> findOrCreateFirebaseApp({
}

final creatingAppSpinner = spinner(
(done) {
(done) {
if (!done) {
return AnsiStyles.bold(
'Registering new Firebase ${AnsiStyles.cyan(platform)} app on Firebase project ${AnsiStyles.cyan(project)}.',
Expand Down Expand Up @@ -519,7 +519,7 @@ Future<String> getAccessToken() async {
: Platform.environment['HOME']!;
// Path to 'firebase-tools.json'
final configPath =
path.join(homeDir, '.config', 'configstore', 'firebase-tools.json');
path.join(homeDir, '.config', 'configstore', 'firebase-tools.json');
final configFile = File(configPath);
if (!configFile.existsSync()) {
throw Exception(
Expand All @@ -536,7 +536,7 @@ Future<String> getAccessToken() async {
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
// 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
body:
'grant_type=refresh_token&client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&client_secret=j9iVZfS8kkCEFUPaAeJV0sAi&refresh_token=$refreshToken',
'grant_type=refresh_token&client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&client_secret=j9iVZfS8kkCEFUPaAeJV0sAi&refresh_token=$refreshToken',
);

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

// Return string value of "GoogleService-Info.plist" or "google-services.json" file for relevant platform
Future<String> getServiceFileContent(
String projectId,
String appId,
String accessToken,
String platform,
) async {
String projectId,
String appId,
String accessToken,
String platform,
) async {
String? uri;

if (platform == kIos || platform == kMacos) {
uri =
'https://firebase.googleapis.com/v1beta1/projects/$projectId/iosApps/$appId/config';
'https://firebase.googleapis.com/v1beta1/projects/$projectId/iosApps/$appId/config';
} else if (platform == kAndroid) {
uri =
'https://firebase.googleapis.com/v1beta1/projects/$projectId/androidApps/$appId/config';
'https://firebase.googleapis.com/v1beta1/projects/$projectId/androidApps/$appId/config';
} else {
throw ServiceFileException(
platform,
Expand Down
Loading