Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Badge inspector tab for structured inspector errors (Flutter.error) #2576

Merged
merged 2 commits into from
Dec 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/devtools_app/lib/src/error_badge_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:vm_service/vm_service.dart';

import 'auto_dispose.dart';
import 'globals.dart';
import 'inspector/inspector_screen.dart';
import 'listenable.dart';
import 'logging/logging_screen.dart';
import 'network/network_screen.dart';
Expand All @@ -16,8 +17,9 @@ import 'vm_service_wrapper.dart';
class ErrorBadgeManager extends DisposableController
with AutoDisposeControllerMixin {
final _activeErrorCounts = <String, ValueNotifier<int>>{
LoggingScreen.id: ValueNotifier<int>(0),
InspectorScreen.id: ValueNotifier<int>(0),
NetworkScreen.id: ValueNotifier<int>(0),
LoggingScreen.id: ValueNotifier<int>(0),
};

void vmServiceOpened(VmServiceWrapper service) {
Expand All @@ -36,9 +38,14 @@ class ErrorBadgeManager extends DisposableController
}

void _handleExtensionEvent(Event e) async {
// TODO(jacobr): badge inspector for appropriate errors.
if (e.extensionKind == 'Flutter.Error') {
incrementBadgeCount(LoggingScreen.id);

final json = e.extensionData.data;
final objectId = json['objectId'] as String;
if (objectId?.contains('inspector-') ?? false) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this check include things we don't want to badge the inspector for? @jacob314

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All object ids sent with errors will start with inspector- currently so this won't really check for much. I think just assuming any case with an objectId is an inspector error is fine for now. We could add a TODO to verify that the objectId is referring to an Element or Widget (may require another round trip unless the json also contains the object type which it may.

incrementBadgeCount(InspectorScreen.id);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/devtools_app/test/error_badge_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import 'package:devtools_app/src/profiler/profiler_screen.dart';
import 'package:flutter_test/flutter_test.dart';

const supportedScreenIds = [
LoggingScreen.id,
InspectorScreen.id,
NetworkScreen.id,
LoggingScreen.id,
];

const allScreenIds = [
Expand Down