Skip to content

fix: add newline at end of firebase_options.dart#438

Open
karnemanideep wants to merge 2 commits intoinvertase:mainfrom
karnemanideep:fix/firebase-options-newline
Open

fix: add newline at end of firebase_options.dart#438
karnemanideep wants to merge 2 commits intoinvertase:mainfrom
karnemanideep:fix/firebase-options-newline

Conversation

@karnemanideep
Copy link
Copy Markdown

Description

flutterfire configure generates firebase_options.dart
without a newline at the end of the file.

This causes dart format to modify the generated file
every time it is run, resulting in:

  • Unnecessary changes in git diff
  • CI/CD pipeline failures when dart format check is enabled
  • Confusion for developers seeing unexpected file changes

##How I Found It

Searched for writeAsStringSync across the codebase to
find where firebase_options.dart content is written.

This led to:
packages/flutterfire_cli/lib/src/firebase/firebase_dart_configuration_write.dart

Inside this file, two functions build and return the
content of firebase_options.dart as a string using
.join('\n') — which joins lines with newlines BETWEEN
them but does NOT add a newline at the END of the file.

##What I Changed

File:
packages/flutterfire_cli/lib/src/firebase/firebase_dart_configuration_write.dart

Line 180 — inside _updateExistingConfigurationFile():

// Before ❌
return formatList(fileConfigurationLines).join('\n');

// After ✅
return '${formatList(fileConfigurationLines).join('\n')}\n';

Line 187 — inside _buildConfigurationFile():

// Before ❌
return formatList(_stringBuffer.toString().split('\n')).join('\n');

// After ✅
return '${formatList(_stringBuffer.toString().split('\n')).join('\n')}\n';

The \n appended at the end ensures the generated
firebase_options.dart always ends with a newline,
satisfying dart format requirements.

  • feat -- New feature (non-breaking change which adds functionality)
  • 🛠️ fix -- Bug fix (non-breaking change which fixes an issue)
  • ! -- Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 refactor -- Code refactor
  • ci -- Build configuration change
  • 📝 docs -- Documentation
  • 🗑️ chore -- Chore

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 18, 2026

CLA assistant check
All committers have signed the CLA.

@karnemanideep
Copy link
Copy Markdown
Author

I've opened a PR to fix this issue.
PR: #438

@github-actions github-actions bot added the Needs Attention OP created or responded to issue and it needs attention. label Apr 18, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the Firebase configuration writer to ensure generated files end with a trailing newline. While the change to the file configuration lines is correct, a review comment points out that the change in _buildConfigurationFile likely introduces a redundant double newline because the underlying string buffer already contains a trailing newline character.

Comment thread packages/flutterfire_cli/lib/src/firebase/firebase_dart_configuration_write.dart Outdated
…uration_write.dart


revert: remove double newline in _buildConfigurationFile
as _stringBuffer already includes trailing newline via writeln()

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@karnemanideep
Copy link
Copy Markdown
Author

Hi @russellwheatley!

Applied the suggested fix from Gemini
for line 187. The CI checks are awaiting
your approval to run.

Could you please take a look when
you get a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Attention OP created or responded to issue and it needs attention.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants