Riding the Wave with Flutter 3.50 & Dart 3.14: A Real-World Migration Guide to google_sign_in v7 (Credential Manager) and FlutterFire v7

What actually changes when upgrading the SDK, Gradle 9.5, AGP 9.3, Google authentication, and the Firebase suite in a production app — including the hidden font-loading gotcha in Flutter 3.50 tests.

1. Why migrate the ecosystem as a coordinated block?

Upgrading dependencies in a toy project rarely takes more than flutter pub upgrade --major-versions. In a live production app — with tens of thousands of lines in Clean Architecture, 18-language support, a heavy automated test suite, and AOT-compiled Dart workers running on Google Cloud Run — the story is completely different.

Deferring structural upgrades creates a silent domino effect: the sign-in plugin locks compileSdk, which locks the Android Gradle Plugin (AGP), blocking the latest Firebase suite and drifting CI/CD environments away from local developer machines.

This week, we upgraded pwE (Pray With Me) end-to-end to Flutter 3.50.0 and Dart 3.14.0, reaching zero outdated packages in flutter pub outdated. In this guide, I share the exact migration path, the real breaking API contracts, and three pitfalls that surface-level release notes don't highlight upfront.

Technology Jump Matrix

Layer / PackageBeforeAfterPrimary Impact
Flutter / Dart SDK3.47.5 / 3.13.x3.50.0 / 3.14.0New fontsChange lifecycle in widget tests and consolidated native features in the AOT compiler
Android ToolchainGradle 9.3.1 · AGP 9.1.0 · Kotlin 2.4.0Gradle 9.5.0 · AGP 9.3.1 · Kotlin 2.4.20compileSdk >= 37 required by AndroidX libraries and Credential Manager
google_sign_in^6.2.1^7.2.0Full API redesign: Credential Manager (Android), GIDSignIn 9 (iOS), singleton, and OIDC separation
FlutterFire SuiteCore v4 / Auth v6 / Firestore v6Core ^5.1.0 / Auth ^7.0.1 / Firestore ^7.1.0Coordinated upgrade of 9 official packages + mock testing counterparts
Satellite Ecosystempurchases_flutter ^10 · ML Kit ^0.17 · Notif. ^22purchases_flutter ^11.0.2 · ML Kit ^1.0.3 · Notif. ^23.0.2New syncPurchasesForResult() contract and ML Kit 1.x stabilization

2. Hardening the Android Toolchain and CI/AOT Parity

The first friction point when bumping google_sign_in ^7.2.0 alongside the latest FlutterFire suite and flutter_local_notifications ^23.0.2 surfaces during the native Android build: transitive Jetpack/AndroidX dependencies now require compileSdk 37.

Instead of hardcoding a magic integer that could go stale once Flutter raises its own internal default in future releases, we used a defensive expression in android/app/build.gradle.kts:

kotlin
android {
    namespace = "com.example.app"
    compileSdk = maxOf(flutter.compileSdkVersion, 37)
    ndkVersion = flutter.ndkVersion
}

In lockstep, we upgraded gradle-9.5.0-all.zip, com.android.application to 9.3.1, and org.jetbrains.kotlin.android to 2.4.20.


3. The Big Breaking Change: google_sign_in v6 to v7 (^7.2.0)

Version 7.x of google_sign_in is far from a cosmetic bump: it re-architects the plugin on top of the Credential Manager API on Android and GIDSignIn 9 on iOS, cleanly separating Authentication (who the user is — OpenID Connect / idToken) from Authorization (which Google APIs the app can call — OAuth2 / accessToken).

Here are the 4 structural changes you will need to apply in your data layer:

3.1. No more public constructor (and how to preserve GetIt + Mocktail)

In v6, we instantiated GoogleSignIn(scopes: ..., serverClientId: ...) directly inside our dependency injection container. In v7, the public constructor was removed in favor of the GoogleSignIn.instance singleton.

To avoid coupling AuthRemoteDataSource to direct static calls (which would break unit testing with Mocktail), we kept constructor injection intact by registering the singleton instance inside GetIt:

dart
// Before (v6)
sl.registerLazySingleton(
  () => GoogleSignIn(
    clientId: kIsWeb ? DefaultFirebaseOptions.webClientId : null,
    serverClientId: DefaultFirebaseOptions.webClientId,
    scopes: ['email', 'profile'],
  ),
);

// After (v7) — 100% mockable in unit tests
sl.registerLazySingleton<GoogleSignIn>(() => GoogleSignIn.instance);

3.2. Explicit, asynchronous, and idempotent initialization

In google_sign_in v7, calling authenticate() or signOut() before initialize() throws a state error. Furthermore, initialize() must complete before any auth operation, yet if it fails due to a transient hiccup, subsequent attempts must be able to retry cleanly.

We solved this by encapsulating a memoized Future<void>? with automatic error reset inside AuthRemoteDataSourceImpl:

dart
Future<void>? _googleSignInInitFuture;

Future<void> _ensureGoogleSignInInitialized() {
  if (_isWeb) return Future<void>.value();
  return _googleSignInInitFuture ??= googleSignIn
      .initialize(serverClientId: DefaultFirebaseOptions.webClientId)
      .catchError((Object e) {
        _googleSignInInitFuture = null;
        throw e;
      });
}

3.3. Goodbye signIn() returning null: typed exceptions and synchronous authentication

Three contract changes happen simultaneously in the main sign-in flow:

  • signIn() is replaced by authenticate(scopeHint: ...), which always returns a non-null GoogleSignInAccount or throws a GoogleSignInException.
  • User cancellation is no longer a null return value — it now arrives as GoogleSignInExceptionCode.canceled (while network drops surface as interrupted).
  • googleUser.authentication is no longer a Future — it is now a synchronous getter, and authenticating with Firebase Auth only requires the OIDC idToken (no OAuth accessToken needed):
dart
// Before (v6)
final GoogleSignInAccount? googleUser = await googleSignIn.signIn();
if (googleUser == null) {
  throw const ServerException('Sign-in canceled by user.');
}
final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
final credential = GoogleAuthProvider.credential(
  accessToken: googleAuth.accessToken,
  idToken: googleAuth.idToken,
);

// After (v7)
await _ensureGoogleSignInInitialized();
final GoogleSignInAccount googleUser;
try {
  googleUser = await googleSignIn.authenticate(
    scopeHint: const <String>['email', 'profile'],
  );
} on GoogleSignInException catch (e) {
  if (e.code == GoogleSignInExceptionCode.canceled) {
    throw const ServerException('Sign-in canceled by user.');
  }
  rethrow;
}

// Synchronous getter and lean OIDC idToken credential
final GoogleSignInAuthentication googleAuth = googleUser.authentication;
final credential = GoogleAuthProvider.credential(
  idToken: googleAuth.idToken,
);

3.4. Silent re-authentication with attemptLightweightAuthentication()

In sensitive flows such as permanent account deletion (GDPR/LGPD), Firebase requires recent authentication (requires-recent-login). In v6, we called signInSilently(reAuthenticate: true).

In v7, the semantic replacement is attemptLightweightAuthentication(), which attempts to refresh credentials with minimal or zero UI friction via Credential Manager; if it returns null (or lacks an idToken), we safely fall back to interactive authenticate(), verifying that the selected email matches the active user account.


4. FlutterFire v7, RevenueCat v11, and Strict Lints in Dart 3.14

With the SDK and Google Sign-In aligned, we atomically upgraded the entire FlutterFire family (firebase_core ^5.1.0, firebase_auth ^7.0.1, cloud_firestore ^7.1.0, firebase_messaging ^17.0.1, firebase_crashlytics ^6.0.1, firebase_remote_config ^7.0.1, firebase_analytics ^13.0.1, firebase_performance ^0.12.1, and firebase_app_check ^0.5.1) alongside their test counterparts (fake_cloud_firestore ^4.5.0 and firebase_auth_mocks ^0.16.0).

Two targeted adjustments deserve special attention in this batch:

  • RevenueCat (purchases_flutter ^11.0.2): Purchases.syncPurchases() was replaced by await Purchases.syncPurchasesForResult(), returning a structured sync result before local customer cache invalidation.
  • GetIt in test tearDown on Dart 3.14: Under strict static analysis (strict-inference + unawaited future lints), calls to sl.unregister<T>() inside setUp, tearDown, and addTearDown(() async { ... }) must be explicitly awaited with await.

5. The "Final Boss" in Flutter 3.50 Tests: RelayoutWhenSystemFontsChangeMixin

Everything compiled cleanly, the app ran smoothly on physical hardware, and static analysis reported 0 issues... until we ran our full widget test suite on Flutter 3.50.0.

Several widget tests began failing subtly during widget tree teardown due to pending transient frame callbacks that never occurred on Flutter 3.47.5.

The Definitive Fix: Global Preloading in flutter_test_config.dart

Instead of scattering arbitrary extra pump() calls across hundreds of tests, we solved the root cause globally using test/flutter_test_config.dart. We disabled runtime HTTP fetching (allowRuntimeFetching = false), triggered registration of all static font variants bundled in assets/fonts/, and awaited await GoogleFonts.pendingFonts() once before testMain():

dart
// test/flutter_test_config.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:google_fonts/google_fonts.dart';

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
  TestWidgetsFlutterBinding.ensureInitialized();
  GoogleFonts.config.allowRuntimeFetching = false;

  // Eagerly register all static font variants bundled in assets/fonts/
  for (final weight in const [
    FontWeight.w400,
    FontWeight.w500,
    FontWeight.w600,
    FontWeight.w700,
  ]) {
    GoogleFonts.cinzel(fontWeight: weight);
    GoogleFonts.inter(fontWeight: weight, fontStyle: FontStyle.normal);
    GoogleFonts.inter(fontWeight: weight, fontStyle: FontStyle.italic);
    GoogleFonts.lora(fontWeight: weight, fontStyle: FontStyle.normal);
    GoogleFonts.lora(fontWeight: weight, fontStyle: FontStyle.italic);
  }

  // Drain all FontLoader.load() futures and fontsChange notifications BEFORE the 1st test
  await GoogleFonts.pendingFonts();
  await testMain();
}

The impact was immediate: 100% offline determinism and zero late fontsChange notifications across concurrent test execution (flutter test --concurrency=4).


6. Quick Migration Checklist

If you are upgrading your project to Flutter 3.50 / Dart 3.14 this week, follow this sequence to avoid rework:

  1. Align the SDK across every environment (local workstation, GitHub Actions, Cloud Build, and Dart worker Dockerfiles).
  2. Upgrade the Android Toolchain first: Gradle 9.5.0, AGP 9.3.1, Kotlin 2.4.20, and compileSdk = maxOf(flutter.compileSdkVersion, 37).
  3. Bump the FlutterFire v7 suite atomically (including fake_cloud_firestore and firebase_auth_mocks in dev_dependencies).
  4. Refactor google_sign_in to ^7.2.0: inject GoogleSignIn.instance via DI, enforce idempotent initialize(), replace signIn() with authenticate() catching GoogleSignInException, remove await from googleUser.authentication, and migrate silent sign-in to attemptLightweightAuthentication().
  5. Harden test/flutter_test_config.dart by awaiting GoogleFonts.pendingFonts() prior to testMain().
  6. Validate the full dependency graph with flutter pub outdated, flutter analyze, and a real sign-in / re-authentication pass on a physical device (where Credential Manager actually runs).

Keeping your core platform up to date takes far less effort when backed by clean architectural boundaries, constructor-based dependency injection, and a trustworthy automated test suite.

GLOBAL PRODUCTION ARCHITECTURE
Explore pwE & Our Architecture Showcase

Check out the live app running on Flutter 3.50 on the Google Play Store (177 countries) and browse our public Architecture Showcase featuring 20 real Clean Code Slices and 79 ADRs:

About the Author · JHH Solutions

Elvis Freitas Lopes Herllain

Software engineering and solutions architecture professional with 10+ years in mission-critical enterprise systems (SRE / L3 RCA) and, in parallel, an independent developer of original products under the JHH Solutions brand.