Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add newWidgetInspector service extension:getRootWidgetTree#150010

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
auto-submit merged 15 commits intoflutter:masterfromelliette:widget-inspector
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
15 commits
Select commitHold shift + click to select a range
2467afb
Add new service extenstion getRootWidgetTree
ellietteJun 5, 2024
bbf4691
Merge in branch refactor-widget-tree-tests
ellietteJun 7, 2024
a94f806
Add summary tree tests for getRootWidgetTree API
ellietteJun 7, 2024
2c186bf
Add tests for getting the full widget tree
ellietteJun 8, 2024
9caf753
Merge branch 'master' into widget-inspector
ellietteJun 8, 2024
1987474
Clean up
ellietteJun 8, 2024
d3e24c3
More clean up
ellietteJun 10, 2024
a63e608
Merge branch 'master' into widget-inspector
ellietteJun 10, 2024
de2f47c
Respond to PR comments
ellietteJun 10, 2024
9f2ef16
Missed some trailing commas
ellietteJun 10, 2024
073a1b2
Merge branch 'master' into widget-inspector
ellietteJun 10, 2024
1e4a432
Remove deprecations
ellietteJun 10, 2024
925f730
Fix test failures
ellietteJun 10, 2024
1259e00
Merge branch 'master' into widget-inspector
ellietteJun 11, 2024
888ce80
Merge branch 'master' into widget-inspector
ellietteJun 11, 2024
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
PrevPrevious commit
NextNext commit
Respond to PR comments
  • Loading branch information
@elliette
elliette committedJun 10, 2024
commitde2f47c5e725fe9e6b2dccaeda869f72c7b1e8f2
4 changes: 2 additions & 2 deletionspackages/flutter/lib/src/widgets/service_extensions.dart
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,7 +393,7 @@ enum WidgetInspectorServiceExtensions {
/// * [WidgetInspectorService.initServiceExtensions], where the service
/// extension is registered.
///
/// !!IMPORTANT!! Please use [getRootWidgetTree] instead.
@Deprecated('UsegetRootWidgetTree instead.')
getRootWidgetSummaryTree,

/// Name of service extension that, when called, will return the
Expand All@@ -409,7 +409,7 @@ enum WidgetInspectorServiceExtensions {
/// * [WidgetInspectorService.initServiceExtensions], where the service
/// extension is registered.
///
/// !!IMPORTANT!! Please use [getRootWidgetTree] instead.
@Deprecated('UsegetRootWidgetTree instead.')
getRootWidgetSummaryTreeWithPreviews,

/// Name of service extension that, when called, will return the details
Expand Down
20 changes: 10 additions & 10 deletionspackages/flutter/lib/src/widgets/widget_inspector.dart
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1969,7 +1969,10 @@ mixin WidgetInspectorService {
) {
final String groupName = parameters['groupName']!;
final Map<String, Object?>? result = _getRootWidgetTreeImpl(
groupName: groupName, isSummaryTree: true, withPreviews: true);
groupName: groupName,
isSummaryTree: true,
withPreviews: true,
);
return Future<Map<String, dynamic>>.value(<String, dynamic>{
'result': result,
});
Expand DownExpand Up@@ -2007,15 +2010,12 @@ mixin WidgetInspectorService {
// Combine the given addAdditionalPropertiesCallback with logic to add text
// previews as well (if withPreviews is true):
Map<String, Object>? combinedAddAdditionalPropertiesCallback(
DiagnosticsNode node, InspectorSerializationDelegate delegate) {
Map<String, Object> additionalPropertiesJson = <String, Object>{};
if (addAdditionalPropertiesCallback != null) {
final Map<String, Object>? json =
addAdditionalPropertiesCallback(node, delegate);
if (json != null) {
additionalPropertiesJson = json;
}
}
DiagnosticsNode node,
InspectorSerializationDelegate delegate,
) {
final Map<String, Object> additionalPropertiesJson =
addAdditionalPropertiesCallback?.call(node, delegate) ??
<String, Object>{};
if (!withPreviews) {
return additionalPropertiesJson;
}
Expand Down
68 changes: 39 additions & 29 deletionspackages/flutter/test/widgets/widget_inspector_test.dart
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1979,20 +1979,23 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {

/// Returns whether the child was created by the local project.
bool wasCreatedByLocalProject(Map<String, Object?> childJson) {
return childJson['createdByLocalProject'] != null &&
childJson['createdByLocalProject'] == true;
return childJson['createdByLocalProject'] == true;
}

/// Returns whether the child has a description matching [description].
bool hasDescription(Map<String, Object?> childJson, {required String description}) {
return childJson['description'] != null &&
childJson['description'] == description;
bool hasDescription(
Map<String, Object?> childJson, {
required String description,
}) {
return childJson['description'] == description;
}

/// Returns whether the child has a text preview matching [preview].
bool hasTextPreview(Map<String, Object?> childJson, {required String preview}) {
return childJson['textPreview'] != null &&
childJson['textPreview'] == preview;
bool hasTextPreview(
Map<String, Object?> childJson, {
required String preview,
}) {
return childJson['textPreview'] == preview;
}

/// Verifies that the children from the JSON response are identical to
Expand DownExpand Up@@ -2076,12 +2079,10 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
}

bool allChildrenSatisfyCondition(Map<String, Object?> treeRoot,
{required bool Function(Map<String, Object?> child) condition}) {
{
required bool Function(Map<String, Object?> child) condition,
}) {
final List<Object?> children = childrenFromJsonResponse(treeRoot);
if (children.isEmpty) {
return true;
}

for (int childIdx = 0; childIdx < children.length; childIdx++) {
final Map<String, Object?> child =
children[childIdx]! as Map<String, Object?>;
Expand All@@ -2097,12 +2098,10 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
}

bool oneChildSatisfiesCondition(Map<String, Object?> treeRoot,
{required bool Function(Map<String, Object?> child) condition}) {
{
required bool Function(Map<String, Object?> child) condition,
}) {
final List<Object?> children = childrenFromJsonResponse(treeRoot);
if (children.isEmpty) {
return false;
}

for (int childIdx = 0; childIdx < children.length; childIdx++) {
final Map<String, Object?> child =
children[childIdx]! as Map<String, Object?>;
Expand DownExpand Up@@ -2209,8 +2208,10 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {

expect(
allChildrenSatisfyCondition(rootJson,
condition: wasCreatedByLocalProject),
isTrue);
condition: wasCreatedByLocalProject,
),
isTrue,
);
await verifyChildrenMatchOtherApi(rootJson, group: group);
});

Expand DownExpand Up@@ -2241,8 +2242,10 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {

expect(
allChildrenSatisfyCondition(rootJson,
condition: wasCreatedByLocalProject),
isTrue);
condition: wasCreatedByLocalProject,
),
isTrue,
);
await verifyChildrenMatchOtherApi(
rootJson,
group: group,
Expand DownExpand Up@@ -2285,23 +2288,26 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
return hasDescription(child, description: 'Text') &&
wasCreatedByLocalProject(child) &&
!hasTextPreview(child, preview: 'a');
}),
},
),
isTrue,
);
expect(
oneChildSatisfiesCondition(rootJson, condition: (Map<String, Object?> child) {
return hasDescription(child, description: 'Text') &&
wasCreatedByLocalProject(child) &&
!hasTextPreview(child, preview: 'b');
}),
},
),
isTrue,
);
expect(
oneChildSatisfiesCondition(rootJson, condition: (Map<String, Object?> child) {
return hasDescription(child, description: 'Text') &&
wasCreatedByLocalProject(child) &&
!hasTextPreview(child, preview: 'c');
}),
},
),
isTrue,
);
});
Expand DownExpand Up@@ -2332,31 +2338,35 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {

expect(
allChildrenSatisfyCondition(rootJson,
condition: wasCreatedByLocalProject),
condition: wasCreatedByLocalProject,
),
isFalse,
);
expect(
oneChildSatisfiesCondition(rootJson, condition: (Map<String, Object?> child) {
return hasDescription(child, description: 'Text') &&
wasCreatedByLocalProject(child) &&
hasTextPreview(child, preview: 'a');
}),
},
),
isTrue,
);
expect(
oneChildSatisfiesCondition(rootJson, condition: (Map<String, Object?> child) {
return hasDescription(child, description: 'Text') &&
wasCreatedByLocalProject(child) &&
hasTextPreview(child, preview: 'b');
}),
},
),
isTrue,
);
expect(
oneChildSatisfiesCondition(rootJson, condition: (Map<String, Object?> child) {
return hasDescription(child, description: 'Text') &&
wasCreatedByLocalProject(child) &&
hasTextPreview(child, preview: 'c');
}),
},
),
isTrue,
);
});
Expand Down

[8]ページ先頭

©2009-2026 Movatter.jp