Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

firebase_options.dart does not exist in a Flutter project

ErrorTarget of URI doesn't exist: 'firebase_options.dart'.

Short answer

firebase_options.dart is not part of a normal Flutter project. The FlutterFire CLI generates it in lib/ when you run flutterfire configure from the project folder. If the import fails, you have not run it yet, you ran it elsewhere, or you added a platform since. Run it again and import the file in main.dart.

  • Applies to firebase_core latest, FlutterFire CLI, Flutter 3.35
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check whether the file exists in lib/ of the project you are running.

    ls lib/firebase_options.dart
  2. 2Match what you see, then jump to its fix

    1. 1ls says No such file, and tutorials mention a file you do not haveflutterfire configure was never runFix
    2. 2The file exists somewhere else, or main.dart does not import itYou ran it in another folder, or the import is missingFix
    3. 3The file exists, but a platform you added has no optionsA new platform or Firebase product was added after configuringFix

What does the error look like?

  • Target of URI doesn't exist: 'firebase_options.dart'.
  • Undefined name 'DefaultFirebaseOptions'.

Cause 1 of 3

flutterfire configure was never run

1Check

The Firebase setup guide says the configure step creates firebase_options.dart and adds it to lib/.

dart pub global list | grep flutterfire

2Fix

Install the tools, then run configure from the Flutter project directory.

firebase login
dart pub global activate flutterfire_cli
flutterfire configure

3Verify

The file now exists.

ls lib/firebase_options.dart

Confirmed by firebase.google.com

Did this fix it?

Cause 2 of 3

You ran it in another folder, or the import is missing

1Check

The guide runs the command from your Flutter project directory, and main.dart imports firebase_options.dart next to firebase_core.

grep -n "firebase_options" lib/main.dart

2Fix

Run configure in the project root, and initialize Firebase with the generated options before runApp.

import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  runApp(const MyApp());
}

3Verify

Rebuild; the analyzer shows no missing import.

flutter pub add firebase_core && flutter run

Confirmed by firebase.google.com

Did this fix it?

Cause 3 of 3

A new platform or Firebase product was added after configuring

1Check

The guide says to run flutterfire configure again when you add a platform or Firebase product.

git log --oneline -3 -- lib/firebase_options.dart

2Fix

Run configure again and select the new platforms.

flutterfire configure

3Verify

Run the app on the new platform.

flutter run

Confirmed by firebase.google.com

Did this fix it?

How do I stop it coming back?

  • Commit firebase_options.dart so teammates do not have to regenerate it.
  • Re-run flutterfire configure whenever you add a platform.
  • Call WidgetsFlutterBinding.ensureInitialized() before Firebase.initializeApp.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.