close

[Solved] Error: Method not found: ‘Error.throwWithStackTrace’. Error.throwWithStackTrace(exception, stackTrace)

Hello Guys, How are you all? Hope You all Are Fine. Today I am facing the following error Error: Method not found: ‘Error.throwWithStackTrace’. Error.throwWithStackTrace(exception, stackTrace) in Flutter. So Here I am Explaining to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Error: Method not found: ‘Error.throwWithStackTrace’. Error.throwWithStackTrace(exception, stackTrace) Occurs?

Today I am facing the following error.

Error: Method not found: 'Error.throwWithStackTrace'. Error.throwWithStackTrace(exception, stackTrace)

How To Solve Error: Method not found: ‘Error.throwWithStackTrace’. Error.throwWithStackTrace(exception, stackTrace)?

  1. Error: Method not found: 'Error.throwWithStackTrace'. Error.throwWithStackTrace(exception, stackTrace)

    To Solve Error: Method not found: 'Error.throwWithStackTrace'. Error.throwWithStackTrace(exception, stackTrace) If You are using multiple firebase services, Then Just add this all into your dependency_overrides of your pubspeck.yaml. Here is my example. Now, Your error will be solved.

  2. How To Solve Error: Method not found: 'Error.throwWithStackTrace'. Error.throwWithStackTrace(exception, stackTrace)?

    To Solve Error: Method not found: 'Error.throwWithStackTrace'. Error.throwWithStackTrace(exception, stackTrace) You just need to add override to those packages with older versions will solve this problem. First of all, Open Your pubspeck.yaml file and then add this dependency_overrides. Here is my pubspeck.yaml file’s Example: dependency_overrides: firebase_messaging_platform_interface: 3.1.6 Now, your error must be solved.

Solution 1: Use dependency_overrides

You just need to add override to those packages with older versions will solve this problem. First of all, Open Your pubspeck.yaml file and then add this dependency_overrides. Here is my pubspeck.yaml file’s Example.

dependency_overrides:
  firebase_messaging_platform_interface: 3.1.6

Now, your error must be solved.

Solution 2: For all Firebase Service

If You are using multiple firebase services, Then Just add this all into your dependency_overrides of your pubspeck.yaml. Here is my example.

dependency_overrides:
  firebase_messaging_platform_interface: 3.1.6
  firebase_crashlytics_platform_interface: 3.1.13
  cloud_firestore_platform_interface: 5.4.13
  firebase_auth_platform_interface: 6.1.11
  firebase_storage_platform_interface: 4.0.14
  cloud_functions_platform_interface: 5.0.21
  firebase_analytics_platform_interface: 3.0.5
  firebase_remote_config_platform_interface: 1.0.5
  firebase_dynamic_links_platform_interface: 0.2.0+5
  firebase_performance_platform_interface: 0.1.0+5
  firebase_app_installations_platform_interface: 0.1.0+6

Now, Your error will be solved.

Solution 3: Update Flutter to 2.10

From Dart 2.16 added the throwWithStackTrace method So you need to update your flutter to 2.10. Run this command in your terminal.

flutter upgrade

Summery

It’s all About this issue. Hope all solutions helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

1 thought on “[Solved] Error: Method not found: ‘Error.throwWithStackTrace’. Error.throwWithStackTrace(exception, stackTrace)”

Leave a Comment