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
ddd7e4ea
Unverified
Commit
ddd7e4ea
authored
Aug 04, 2018
by
Jonah Williams
Committed by
GitHub
Aug 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve semantics of chip demo (#20121)
parent
47bdb54e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
22 deletions
+69
-22
chip_demo.dart
examples/flutter_gallery/lib/demo/material/chip_demo.dart
+34
-22
chip_demo_test.dart
...es/flutter_gallery/test/demo/material/chip_demo_test.dart
+35
-0
No files found.
examples/flutter_gallery/lib/demo/material/chip_demo.dart
View file @
ddd7e4ea
...
...
@@ -81,29 +81,41 @@ class _ChipsTile extends StatelessWidget {
// Wraps a list of chips into a ListTile for display as a section in the demo.
@override
Widget
build
(
BuildContext
context
)
{
return
new
ListTile
(
title:
new
Padding
(
final
List
<
Widget
>
cardChildren
=
<
Widget
>[
new
Container
(
padding:
const
EdgeInsets
.
only
(
top:
16.0
,
bottom:
4.0
),
alignment:
Alignment
.
center
,
child:
new
Text
(
label
,
textAlign:
TextAlign
.
start
),
),
subtitle:
children
.
isEmpty
?
new
Center
(
child:
new
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
new
Text
(
'None'
,
style:
Theme
.
of
(
context
).
textTheme
.
caption
.
copyWith
(
fontStyle:
FontStyle
.
italic
),
),
),
)
:
new
Wrap
(
children:
children
.
map
((
Widget
chip
)
=>
new
Padding
(
padding:
const
EdgeInsets
.
all
(
4.0
),
child:
chip
,
))
.
toList
(),
),
];
if
(
children
.
isNotEmpty
)
{
cardChildren
.
add
(
new
Wrap
(
children:
children
.
map
((
Widget
chip
)
{
return
new
Padding
(
padding:
const
EdgeInsets
.
all
(
2.0
),
child:
chip
,
);
}).
toList
()));
}
else
{
final
TextStyle
textStyle
=
Theme
.
of
(
context
).
textTheme
.
caption
.
copyWith
(
fontStyle:
FontStyle
.
italic
);
cardChildren
.
add
(
new
Semantics
(
container:
true
,
child:
new
Container
(
alignment:
Alignment
.
center
,
constraints:
const
BoxConstraints
(
minWidth:
48.0
,
minHeight:
48.0
),
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
new
Text
(
'None'
,
style:
textStyle
),
),
));
}
return
new
Card
(
semanticContainer:
false
,
child:
new
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
cardChildren
,
)
);
}
}
...
...
@@ -297,7 +309,7 @@ class _ChipDemoState extends State<ChipDemo> {
_showShapeBorder
=
!
_showShapeBorder
;
});
},
icon:
const
Icon
(
Icons
.
vignette
),
icon:
const
Icon
(
Icons
.
vignette
,
semanticLabel:
'Update border shape'
),
)
],
),
...
...
@@ -313,7 +325,7 @@ class _ChipDemoState extends State<ChipDemo> {
),
floatingActionButton:
new
FloatingActionButton
(
onPressed:
()
=>
setState
(
_reset
),
child:
const
Icon
(
Icons
.
refresh
),
child:
const
Icon
(
Icons
.
refresh
,
semanticLabel:
'Reset chips'
),
),
);
}
...
...
examples/flutter_gallery/test/demo/material/chip_demo_test.dart
0 → 100644
View file @
ddd7e4ea
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter_gallery/demo/material/chip_demo.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Chip demo has semantic labels'
,
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
await
tester
.
pumpWidget
(
new
MaterialApp
(
theme:
new
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
new
ChipDemo
(),
));
expect
(
tester
.
getSemanticsData
(
find
.
byIcon
(
Icons
.
vignette
)),
matchesSemanticsData
(
isButton:
true
,
hasEnabledState:
true
,
isEnabled:
true
,
hasTapAction:
true
,
label:
'Update border shape'
,
));
expect
(
tester
.
getSemanticsData
(
find
.
byIcon
(
Icons
.
refresh
)),
matchesSemanticsData
(
isButton:
true
,
hasEnabledState:
true
,
isEnabled:
true
,
hasTapAction:
true
,
label:
'Reset chips'
,
));
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