LWB
LWB

Reputation: 514

How do I resolve 'Id does not exist' error?

So I am building a calculator with flutter and after changing some of my code, I have been getting this error whenever I hot restart, I get this error:

======== Exception caught by Flutter framework =====================================================
The following assertion was thrown during a service extension callback for "ext.flutter.inspector.setSelectionById":
Id does not exist.

When the exception was thrown, this was the stack: 
#0      WidgetInspectorService.toObject (package:flutter/src/widgets/widget_inspector.dart:1283:7)
#1      WidgetInspectorService.setSelectionById (package:flutter/src/widgets/widget_inspector.dart:1345:25)
#2      WidgetInspectorService._registerServiceExtensionWithArg.<anonymous closure> (package:flutter/src/widgets/widget_inspector.dart:864:35)
#3      WidgetInspectorService._registerServiceExtensionWithArg.<anonymous closure> (package:flutter/src/widgets/widget_inspector.dart:861:17)
#4      BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:597:32)
...

====================================================================================================

I have no clue what the error means and I cant find and answer to it anywhere. The only thing I can infer is that it is possibly something with the inspector due to "ext.flutter.inspector.setSelectionById" but I honestly have no idea. I also believe it might not be to do with my code since it doesn't reference anything in there. I would extremely appreciate if anyone could at least help me understand the error. If you need more details, just ask me.

Upvotes: 28

Views: 26560

Answers (11)

jeprato
jeprato

Reputation: 51

I just closed widget inspector. Restarted my app and then oppened widget inspector again, the error is gone. Before I tryed restarting app without closing widget inspector, then after reading this post I understand that the infractor was the inspector so I decided to close and reopen it, and it worked.

Upvotes: 2

Pasindu
Pasindu

Reputation: 1

I got the same error, but could fix it as follows;

Delete dart_tool and build folders.

Then run the following commands

  • flutter clean
  • flutter pub global activate devtools.
  • flutter pub get

And restart IDE.

Upvotes: 0

Han Parlak
Han Parlak

Reputation: 777

If you're trying to use DevTools and came up with these outputs in Debug Console, the suggested answers might not do good for you. Simply because some show you "how to avoid" it rather than solving. So, here's my 2 cents about solving this if you want to open up DevTools or Widget Inspector to debug your app.

This bug may have been fixed on newer versions (of devtools?) (or of Dart?) but I couldn't manage to solve it by simply "activating devtools globally". So I had to do some ugly stuff but eventually, I've managed to solve it.


My fixpaghetti steps are as below:

  1. Stop debugging the app
  2. Uninstall the app from device
  3. Delete <project-dir>/build folder
  4. run flutter clean from terminal
  5. run cd android && .\gradlew clean (cd android ; .\gradlew clean if you're on powershell)
  6. run flutter pub global activate devtools
  7. run flutter pub get and wait for IDE to resolve errors (if it automatically does not, restart the IDE)
  8. run the app

and add some prayers along the way. Hope you'll fix it!

Upvotes: 2

JiajunHu
JiajunHu

Reputation: 1

You should close your compiler and open it again!!! (maybe you've changed the ui so much)

Upvotes: -2

i am in office2
i am in office2

Reputation: 11

After restarting the app it failed to build showing an error in app level build.gradle so

  1. commented multidex true at default config // multiDexEnable true

multidex xommenting 2. commented its implementation in the dependencies // implementation 'com.android.support:multidex:1.0.3'

dependency commenting

Upvotes: 1

Siddharth Mehra
Siddharth Mehra

Reputation: 1899

For me, cleaning the project and rebuilding again solved the problem.

Clean Command:

flutter clean

Pub Get Command:

flutter pub get

Upvotes: 2

Lukk17s
Lukk17s

Reputation: 1036

What helped me:

  1. Stop flutter app on device
  2. Delete .dart_tool and build folders from project tree.
  3. Run fresh flutter app installation on device.

Upvotes: 2

user14624595
user14624595

Reputation: 1084

The error was probably due to Flutter Dev Tools being open.

Upvotes: 55

MendelG
MendelG

Reputation: 20008

This seems to be a bug. See this Github issue:

I don't know if it's a Dart-Code, DevTools or Flutter bug...

Upvotes: 2

Code on the Rocks
Code on the Rocks

Reputation: 17576

I got this error when I tried to show a CupertinoTimerPicker inside a SimpleDialog. I solved it by wrapping the CupertinoTimerPicker in a sized box with a defined height and width:

Center(
              child: SizedBox(
                height: 200,
                width: 200,
                child: CupertinoTimerPicker(
                  initialTimerDuration: tempDuration,
                  onTimerDurationChanged: (value) {
                    print(value.toString());
                    tempDuration = value;
                  },
                ),
              ),
            ),

Upvotes: 3

repleeka
repleeka

Reputation: 610

I cannot explain why is this happening? But I solved the problem without restarting the whole app.

My Solution:

I just ran the following command:

flutter pub global activate devtools

It downloaded and compiled the dependencies needed for the devtools and reactivated the devtools.

Thank you !

Upvotes: 8

Related Questions