0

I am using firebase in flutter application after updating the libraries to the latest version. Below is the code which was previously used but now I am facing error

CODE

void main() {
  FirebaseFirestore.instance.settings(timestampsInSnapshotsEnabled: true).then((_) {
    print("Timestamps enabled in snapshots\n");
  }, onError: (_) {
    print("Error enabling timestamps in snapshots\n");
  });
  runApp(MyApp());
}

ERROR

error: The expression doesn't evaluate to a function, so it can't be invoked.

when I am implementing the above code I get the error, please help me to resolve this

1
  • As far as I know, the timestampsInSnapshotsEnabled setting is non longer needed. Commented May 15, 2021 at 14:10

2 Answers 2

1

Here's a code that should fix it.

    Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}
Sign up to request clarification or add additional context in comments.

Comments

0

You need to Initialize the Firebase instance before runApp(MyApp());

void main() async{

     WidgetsFlutterBinding.ensureInitialized();
      
     await Firebase.initializeApp();
     //Before running App During load time initialize firebase instance.

     runApp(MyApp());
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.