Skip to content

fix(ui_oauth): initialize Firebase in the example app - #753

Open
aebrahim wants to merge 1 commit into
firebase:mainfrom
aebrahim:fix/oauth-example-firebase-init
Open

aebrahim wants to merge 1 commit into
firebase:mainfrom
aebrahim:fix/oauth-example-firebase-init

Conversation

@aebrahim

@aebrahim aebrahim commented Nov 18, 2026 •

Copy link
Copy Markdown

The firebase_ui_oauth example app never calls Firebase.initializeApp(). OAuthProviderButtonBase resolves FirebaseAuth.instance in initState, so every button throws on startup ("Null check operator used on a null value" from Firebase.app() on web) and the example renders error widgets instead of the provider buttons.

This initializes Firebase with the example's existing firebase_options.dart, matching the other example apps in the repo (firebase_ui_auth, firebase_ui_firestore, firebase_ui_database, firebase_ui_storage, firebase_ui_localizations).

  • dart analyze --fatal-infos reports no issues in the example.
  • flutter build web succeeds. In a headless browser the app now renders the Apple, Facebook, Google and Twitter buttons with their icons, with no console errors. Before this change the button area was an error widget.
  • melos run analyze and melos run test:unit:all pass.

Found while testing #752.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors.
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • All unit tests pass (melos run test:unit:all doesn't fail).
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

The `firebase_ui_oauth` example app never calls `Firebase.initializeApp()`.
`OAuthProviderButtonBase` resolves `FirebaseAuth.instance` in `initState`, so
every button throws on startup ("Null check operator used on a null value"
from `Firebase.app()` on web) and the example renders error widgets instead
of the provider buttons.

This initializes Firebase with the example's existing
`firebase_options.dart`, matching the other example apps in the repo
(`firebase_ui_auth`, `firebase_ui_firestore`, `firebase_ui_database`,
`firebase_ui_storage`, `firebase_ui_localizations`).

- `dart analyze --fatal-infos` reports no issues in the example.
- `flutter build web` succeeds. In a headless browser the app now renders
  the Apple, Facebook, Google and Twitter buttons with their icons, with no
  console errors. Before this change the button area was an error widget.
- `melos run analyze` and `melos run test:unit:all` pass.

Found while testing firebase#752.

- [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] My PR includes unit or integration tests for _all_ changed/updated/fixed behaviors.
- [x] All existing and new tests are passing.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] The analyzer (`melos run analyze`) does not report any problems on my PR.
- [x] All unit tests pass (`melos run test:unit:all` doesn't fail).
- [x] I read and followed the Flutter Style Guide.
- [x] I signed the CLA.
- [x] I am willing to follow-up on review comments in a timely manner.

- [ ] Yes, this is a breaking change.
- [x] No, this is _not_ a breaking change.

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

Copy link
Copy Markdown

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 updates the example application in packages/firebase_ui_oauth to properly initialize Firebase. It adds imports for firebase_core and firebase_options.dart, and invokes Firebase.initializeApp with DefaultFirebaseOptions.currentPlatform in the main function. I have no feedback to provide as there are no review comments.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant