Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
23f7985e
Unverified
Commit
23f7985e
authored
Oct 29, 2021
by
Ian Hickson
Committed by
GitHub
Oct 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve how AttributedStrings are presented in the widget inspector (#92450)
parent
bd935e5d
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
285 additions
and
109 deletions
+285
-109
diagnostics.dart
packages/flutter/lib/src/foundation/diagnostics.dart
+15
-5
semantics.dart
packages/flutter/lib/src/semantics/semantics.dart
+222
-104
semantics_test.dart
packages/flutter/test/semantics/semantics_test.dart
+37
-0
semantics_update_test.dart
packages/flutter/test/semantics/semantics_update_test.dart
+11
-0
No files found.
packages/flutter/lib/src/foundation/diagnostics.dart
View file @
23f7985e
...
...
@@ -2839,14 +2839,23 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
}
}
/// If the [value] of the property equals [defaultValue] the priority [level]
/// of the property is downgraded to [DiagnosticLevel.fine] as the property
/// value is uninteresting.
/// The default value of this property, when it has not been set to a specific
/// value.
///
/// For most [DiagnosticsProperty] classes, if the [value] of the property
/// equals [defaultValue], then the priority [level] of the property is
/// downgraded to [DiagnosticLevel.fine] on the basis that the property value
/// is uninteresting. This is implemented by [isInteresting].
///
/// The [defaultValue] is [kNoDefaultValue] by default. Otherwise it must be of
/// type `T?`.
final
Object
?
defaultValue
;
/// Whether to consider the property's value interesting. When a property is
/// uninteresting, its [level] is downgraded to [DiagnosticLevel.fine]
/// regardless of the value provided as the constructor's `level` argument.
bool
get
isInteresting
=>
defaultValue
==
kNoDefaultValue
||
value
!=
defaultValue
;
final
DiagnosticLevel
_defaultLevel
;
/// Priority level of the diagnostic used to control which diagnostics should
...
...
@@ -2870,8 +2879,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
if
(
value
==
null
&&
missingIfNull
)
return
DiagnosticLevel
.
warning
;
// Use a low level when the value matches the default value.
if
(
defaultValue
!=
kNoDefaultValue
&&
value
==
defaultValue
)
if
(!
isInteresting
)
return
DiagnosticLevel
.
fine
;
return
_defaultLevel
;
...
...
@@ -3549,7 +3557,9 @@ class DiagnosticsBlock extends DiagnosticsNode {
@override
final
DiagnosticLevel
level
;
final
String
?
_description
;
@override
final
Object
?
value
;
...
...
packages/flutter/lib/src/semantics/semantics.dart
View file @
23f7985e
This diff is collapsed.
Click to expand it.
packages/flutter/test/semantics/semantics_test.dart
View file @
23f7985e
...
...
@@ -69,6 +69,10 @@ void main() {
expect
(
config
.
label
,
'label1'
);
expect
(
config
.
attributedLabel
.
string
,
'label1'
);
expect
(
config
.
attributedLabel
.
attributes
.
isEmpty
,
isTrue
);
expect
(
(
SemanticsNode
()..
updateWith
(
config:
config
)).
toString
(),
'SemanticsNode#1(STALE, owner: null, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), invisible, label: "label1")'
,
);
config
.
attributedLabel
=
AttributedString
(
'label2'
,
...
...
@@ -81,16 +85,28 @@ void main() {
expect
(
config
.
attributedLabel
.
attributes
.
length
,
1
);
expect
(
config
.
attributedLabel
.
attributes
[
0
]
is
SpellOutStringAttribute
,
isTrue
);
expect
(
config
.
attributedLabel
.
attributes
[
0
].
range
,
const
TextRange
(
start:
0
,
end:
1
));
expect
(
(
SemanticsNode
()..
updateWith
(
config:
config
)).
toString
(),
'SemanticsNode#2(STALE, owner: null, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), invisible, label: "label2" [SpellOutStringAttribute(TextRange(start: 0, end: 1))])'
,
);
config
.
label
=
'label3'
;
expect
(
config
.
label
,
'label3'
);
expect
(
config
.
attributedLabel
.
string
,
'label3'
);
expect
(
config
.
attributedLabel
.
attributes
.
isEmpty
,
isTrue
);
expect
(
(
SemanticsNode
()..
updateWith
(
config:
config
)).
toString
(),
'SemanticsNode#3(STALE, owner: null, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), invisible, label: "label3")'
,
);
config
.
value
=
'value1'
;
expect
(
config
.
value
,
'value1'
);
expect
(
config
.
attributedValue
.
string
,
'value1'
);
expect
(
config
.
attributedValue
.
attributes
.
isEmpty
,
isTrue
);
expect
(
(
SemanticsNode
()..
updateWith
(
config:
config
)).
toString
(),
'SemanticsNode#4(STALE, owner: null, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), invisible, label: "label3", value: "value1")'
,
);
config
.
attributedValue
=
AttributedString
(
'value2'
,
...
...
@@ -103,16 +119,28 @@ void main() {
expect
(
config
.
attributedValue
.
attributes
.
length
,
1
);
expect
(
config
.
attributedValue
.
attributes
[
0
]
is
SpellOutStringAttribute
,
isTrue
);
expect
(
config
.
attributedValue
.
attributes
[
0
].
range
,
const
TextRange
(
start:
0
,
end:
1
));
expect
(
(
SemanticsNode
()..
updateWith
(
config:
config
)).
toString
(),
'SemanticsNode#5(STALE, owner: null, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), invisible, label: "label3", value: "value2" [SpellOutStringAttribute(TextRange(start: 0, end: 1))])'
,
);
config
.
value
=
'value3'
;
expect
(
config
.
value
,
'value3'
);
expect
(
config
.
attributedValue
.
string
,
'value3'
);
expect
(
config
.
attributedValue
.
attributes
.
isEmpty
,
isTrue
);
expect
(
(
SemanticsNode
()..
updateWith
(
config:
config
)).
toString
(),
'SemanticsNode#6(STALE, owner: null, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), invisible, label: "label3", value: "value3")'
,
);
config
.
hint
=
'hint1'
;
expect
(
config
.
hint
,
'hint1'
);
expect
(
config
.
attributedHint
.
string
,
'hint1'
);
expect
(
config
.
attributedHint
.
attributes
.
isEmpty
,
isTrue
);
expect
(
(
SemanticsNode
()..
updateWith
(
config:
config
)).
toString
(),
'SemanticsNode#7(STALE, owner: null, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), invisible, label: "label3", value: "value3", hint: "hint1")'
,
);
config
.
attributedHint
=
AttributedString
(
'hint2'
,
...
...
@@ -125,11 +153,19 @@ void main() {
expect
(
config
.
attributedHint
.
attributes
.
length
,
1
);
expect
(
config
.
attributedHint
.
attributes
[
0
]
is
SpellOutStringAttribute
,
isTrue
);
expect
(
config
.
attributedHint
.
attributes
[
0
].
range
,
const
TextRange
(
start:
0
,
end:
1
));
expect
(
(
SemanticsNode
()..
updateWith
(
config:
config
)).
toString
(),
'SemanticsNode#8(STALE, owner: null, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), invisible, label: "label3", value: "value3", hint: "hint2" [SpellOutStringAttribute(TextRange(start: 0, end: 1))])'
,
);
config
.
hint
=
'hint3'
;
expect
(
config
.
hint
,
'hint3'
);
expect
(
config
.
attributedHint
.
string
,
'hint3'
);
expect
(
config
.
attributedHint
.
attributes
.
isEmpty
,
isTrue
);
expect
(
(
SemanticsNode
()..
updateWith
(
config:
config
)).
toString
(),
'SemanticsNode#9(STALE, owner: null, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), invisible, label: "label3", value: "value3", hint: "hint3")'
,
);
});
test
(
'mutate existing semantic node list errors'
,
()
{
...
...
@@ -654,6 +690,7 @@ void main() {
expect
(
result
.
attributes
.
length
,
2
);
expect
(
result
.
attributes
[
0
].
range
,
const
TextRange
(
start:
0
,
end:
4
));
expect
(
result
.
attributes
[
0
]
is
SpellOutStringAttribute
,
isTrue
);
expect
(
result
.
toString
(),
"AttributedString('string1string2', attributes: [SpellOutStringAttribute(TextRange(start: 0, end: 4)), LocaleStringAttribute(TextRange(start: 7, end: 11), es-MX)])"
);
});
test
(
'Semantics id does not repeat'
,
()
{
...
...
packages/flutter/test/semantics/semantics_update_test.dart
View file @
23f7985e
...
...
@@ -151,6 +151,17 @@ void main() {
expect
(
SemanticsUpdateBuilderSpy
.
observations
[
1
]!.
hintAttributes
![
0
]
is
SpellOutStringAttribute
,
isTrue
);
expect
(
SemanticsUpdateBuilderSpy
.
observations
[
1
]!.
hintAttributes
![
0
].
range
,
const
TextRange
(
start:
1
,
end:
2
));
expect
(
tester
.
widget
(
find
.
byType
(
Semantics
)).
toString
(),
'Semantics('
'container: false, '
'properties: SemanticsProperties, '
'attributedLabel: "label" [SpellOutStringAttribute(TextRange(start: 0, end: 5))], '
'attributedValue: "value" [LocaleStringAttribute(TextRange(start: 0, end: 5), en-MX)], '
'attributedHint: "hint" [SpellOutStringAttribute(TextRange(start: 1, end: 2))]'
// ignore: missing_whitespace_between_adjacent_strings
')'
,
);
SemanticsUpdateBuilderSpy
.
observations
.
clear
();
handle
.
dispose
();
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment