From 876f33b7e9efcf54792ac169424deb5a60fa9bde Mon Sep 17 00:00:00 2001 From: Ali Ebrahim Date: Wed, 18 Nov 2026 00:08:11 -0800 Subject: [PATCH] fix(ui_oauth): initialize Firebase in the example app 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 https://github.com/firebase/FirebaseUI-Flutter/pull/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. --- packages/firebase_ui_oauth/example/lib/main.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/firebase_ui_oauth/example/lib/main.dart b/packages/firebase_ui_oauth/example/lib/main.dart index a8bffe72..21f3d726 100644 --- a/packages/firebase_ui_oauth/example/lib/main.dart +++ b/packages/firebase_ui_oauth/example/lib/main.dart @@ -2,6 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:firebase_ui_oauth/firebase_ui_oauth.dart'; @@ -10,10 +11,12 @@ import 'package:firebase_ui_oauth_facebook/firebase_ui_oauth_facebook.dart'; import 'package:firebase_ui_oauth_google/firebase_ui_oauth_google.dart'; import 'package:firebase_ui_oauth_twitter/firebase_ui_oauth_twitter.dart'; +import 'firebase_options.dart'; import 'src/settings.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); runApp(const OAuthProviderButtonExample()); }