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
6b09543e
Commit
6b09543e
authored
Oct 03, 2019
by
Mehmet Fidanboylu
Committed by
Michael Goderbauer
Oct 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow customization of label styles for semantics debugger (#41730)
parent
c7c8a6c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
7 deletions
+40
-7
semantics_debugger.dart
packages/flutter/lib/src/widgets/semantics_debugger.dart
+20
-7
semantics_debugger_test.dart
packages/flutter/test/widgets/semantics_debugger_test.dart
+20
-0
No files found.
packages/flutter/lib/src/widgets/semantics_debugger.dart
View file @
6b09543e
...
...
@@ -22,13 +22,28 @@ class SemanticsDebugger extends StatefulWidget {
/// Creates a widget that visualizes the semantics for the child.
///
/// The [child] argument must not be null.
const
SemanticsDebugger
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
///
/// [labelStyle] dictates the [TextStyle] used for the semantics labels.
const
SemanticsDebugger
({
Key
key
,
@required
this
.
child
,
this
.
labelStyle
=
const
TextStyle
(
color:
Color
(
0xFF000000
),
fontSize:
10.0
,
height:
0.8
,
),
})
:
assert
(
child
!=
null
),
assert
(
labelStyle
!=
null
),
super
(
key:
key
);
/// The widget below this widget in the tree.
///
/// {@macro flutter.widgets.child}
final
Widget
child
;
/// The [TextStyle] to use when rendering semantics labels.
final
TextStyle
labelStyle
;
@override
_SemanticsDebuggerState
createState
()
=>
_SemanticsDebuggerState
();
}
...
...
@@ -150,6 +165,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi
_client
.
generation
,
_lastPointerDownLocation
,
// in physical pixels
WidgetsBinding
.
instance
.
window
.
devicePixelRatio
,
widget
.
labelStyle
,
),
child:
GestureDetector
(
behavior:
HitTestBehavior
.
opaque
,
...
...
@@ -195,12 +211,13 @@ class _SemanticsClient extends ChangeNotifier {
}
class
_SemanticsDebuggerPainter
extends
CustomPainter
{
const
_SemanticsDebuggerPainter
(
this
.
owner
,
this
.
generation
,
this
.
pointerPosition
,
this
.
devicePixelRatio
);
const
_SemanticsDebuggerPainter
(
this
.
owner
,
this
.
generation
,
this
.
pointerPosition
,
this
.
devicePixelRatio
,
this
.
labelStyle
);
final
PipelineOwner
owner
;
final
int
generation
;
final
Offset
pointerPosition
;
// in physical pixels
final
double
devicePixelRatio
;
final
TextStyle
labelStyle
;
SemanticsNode
get
_rootSemanticsNode
{
return
owner
.
semanticsOwner
?.
rootSemanticsNode
;
...
...
@@ -306,11 +323,7 @@ class _SemanticsDebuggerPainter extends CustomPainter {
canvas
.
clipRect
(
rect
);
final
TextPainter
textPainter
=
TextPainter
()
..
text
=
TextSpan
(
style:
const
TextStyle
(
color:
Color
(
0xFF000000
),
fontSize:
10.0
,
height:
0.8
,
),
style:
labelStyle
,
text:
message
,
)
..
textDirection
=
TextDirection
.
ltr
// _getMessage always returns LTR text, even if node.label is RTL
...
...
packages/flutter/test/widgets/semantics_debugger_test.dart
View file @
6b09543e
...
...
@@ -460,6 +460,26 @@ void main() {
'textfield'
,
);
});
testWidgets
(
'SemanticsDebugger label style is used in the painter.'
,
(
WidgetTester
tester
)
async
{
final
UniqueKey
debugger
=
UniqueKey
();
const
TextStyle
labelStyle
=
TextStyle
(
color:
Colors
.
amber
);
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
SemanticsDebugger
(
key:
debugger
,
labelStyle:
labelStyle
,
child:
Semantics
(
label:
'label'
,
textDirection:
TextDirection
.
ltr
,
),
),
),
);
expect
(
_getSemanticsDebuggerPainter
(
debuggerKey:
debugger
,
tester:
tester
).
labelStyle
,
labelStyle
);
});
}
String
_getMessageShownInSemanticsDebugger
(
{
...
...
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