Fix variable inspection for `List` and `Map` instances (#5320)

diff --git a/packages/devtools_app/lib/src/shared/diagnostics/dart_object_node.dart b/packages/devtools_app/lib/src/shared/diagnostics/dart_object_node.dart
index fd254d7..4acf1f1 100644
--- a/packages/devtools_app/lib/src/shared/diagnostics/dart_object_node.dart
+++ b/packages/devtools_app/lib/src/shared/diagnostics/dart_object_node.dart
@@ -320,9 +320,15 @@
       if (kind != null && kind == InstanceKind.kList ||
           kind == InstanceKind.kMap ||
           kind!.endsWith('List')) {
+        // TODO(elliette): Determine the signature from type parameters, see:
+        // https://api.flutter.dev/flutter/vm_service/ClassRef/typeParameters.html
+        // DWDS provides us with a readable format including type parameters in
+        // the classRef name, for the vm_service we fall back to just using the
+        // kind:
+        final name = _isPrivateName(valueStr) ? kind : valueStr;
         final itemLength = value.length;
         if (itemLength == null) return valueStr;
-        return '$valueStr (${_itemCount(itemLength)})';
+        return '$name (${_itemCount(itemLength)})';
       }
     } else if (value is Sentinel) {
       valueStr = value.valueAsString;
@@ -337,6 +343,8 @@
     return valueStr;
   }
 
+  bool _isPrivateName(String name) => name.startsWith('_');
+
   static String _itemCount(int count) {
     return '${nf.format(count)} ${pluralize('item', count)}';
   }
diff --git a/packages/devtools_app/lib/src/shared/diagnostics/variable_factory.dart b/packages/devtools_app/lib/src/shared/diagnostics/variable_factory.dart
index d3d6603..0fc789c 100644
--- a/packages/devtools_app/lib/src/shared/diagnostics/variable_factory.dart
+++ b/packages/devtools_app/lib/src/shared/diagnostics/variable_factory.dart
@@ -469,7 +469,7 @@
   final elements = instance.elements ?? [];
   for (int i = 0; i < elements.length; i++) {
     final index = instance.offset == null ? i : i + instance.offset!;
-    final name = '[$index]${instance.classRef!.name}';
+    final name = '[$index]';
 
     variables.add(
       DartObjectNode.fromValue(
diff --git a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
index be3453a..42f7814 100644
--- a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
+++ b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
@@ -28,6 +28,7 @@
 ## Debugger updates
 * Add support for browser navigation history when navigating using the `File Explorer` [#4906](https://github.com/flutter/devtools/pull/4906).
 * Designate positional fields for `Record` types with the getter syntax beginning at `$1` [#5272](https://github.com/flutter/devtools/pull/5272)
+* Fix variable inspection for `Map` and `List` instances: [#5320](https://github.com/flutter/devtools/pull/5320)
 
 ## Network profiler updates
 * Improve reliability and performance of the Network tab - [#5056](https://github.com/flutter/devtools/pull/5056)
diff --git a/packages/devtools_app/test/debugger/debugger_screen_variables_test.dart b/packages/devtools_app/test/debugger/debugger_screen_variables_test.dart
index 85b1587..75fec88 100644
--- a/packages/devtools_app/test/debugger/debugger_screen_variables_test.dart
+++ b/packages/devtools_app/test/debugger/debugger_screen_variables_test.dart
@@ -76,16 +76,16 @@
       await pumpDebuggerScreen(tester, debuggerController);
       expect(find.text('Variables'), findsOneWidget);
 
-      final listFinder = find.selectableText('Root 1: _GrowableList (2 items)');
+      final listFinder = find.selectableText('Root 1: List (2 items)');
 
       // expect a tooltip for the list value
       expect(
-        find.byTooltip('_GrowableList (2 items)'),
+        find.byTooltip('List (2 items)'),
         findsOneWidget,
       );
 
       final mapFinder = find.selectableTextContaining(
-        'Root 2: _InternalLinkedHashmap (2 items)',
+        'Root 2: Map (2 items)',
       );
       final mapElement1Finder = find.selectableTextContaining("['key1']: 1.0");
       final mapElement2Finder = find.selectableTextContaining("['key2']: 2.0");
@@ -135,8 +135,7 @@
 
       await pumpDebuggerScreen(tester, debuggerController);
 
-      final listFinder =
-          find.selectableText('Root 1: _GrowableList (380,250 items)');
+      final listFinder = find.selectableText('Root 1: List (380,250 items)');
       final group0To9999Finder = find.selectableTextContaining('[0 - 9999]');
       final group10000To19999Finder =
           find.selectableTextContaining('[10000 - 19999]');
@@ -193,8 +192,7 @@
 
       await pumpDebuggerScreen(tester, debuggerController);
 
-      final listFinder =
-          find.selectableText('Root 1: _InternalLinkedHashmap (243,621 items)');
+      final listFinder = find.selectableText('Root 1: Map (243,621 items)');
       final group0To9999Finder = find.selectableTextContaining('[0 - 9999]');
       final group10000To19999Finder =
           find.selectableTextContaining('[10000 - 19999]');