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
17ddfb1b
Unverified
Commit
17ddfb1b
authored
Aug 13, 2019
by
MH Johnson
Committed by
GitHub
Aug 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make RawChip.selected non-nullable (#37556)
parent
aa83b284
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
11 deletions
+24
-11
chip.dart
packages/flutter/lib/src/material/chip.dart
+7
-7
chip_test.dart
packages/flutter/test/material/chip_test.dart
+15
-1
chip_theme_test.dart
packages/flutter/test/material/chip_theme_test.dart
+2
-3
No files found.
packages/flutter/lib/src/material/chip.dart
View file @
17ddfb1b
...
...
@@ -1285,8 +1285,8 @@ class RawChip extends StatefulWidget
/// The [onPressed] and [onSelected] callbacks must not both be specified at
/// the same time.
///
/// The [label], [isEnabled],
and [clipBehavior] arguments must not be null.
/// The [pressElevation] and [elevation] must be null or non-negative.
/// The [label], [isEnabled],
[selected], and [clipBehavior] arguments must
///
not be null.
The [pressElevation] and [elevation] must be null or non-negative.
/// Typically, [pressElevation] is greater than [elevation].
const
RawChip
({
Key
key
,
...
...
@@ -1303,7 +1303,7 @@ class RawChip extends StatefulWidget
this
.
onSelected
,
this
.
pressElevation
,
this
.
tapEnabled
=
true
,
this
.
selected
,
this
.
selected
=
false
,
this
.
showCheckmark
=
true
,
this
.
isEnabled
=
true
,
this
.
disabledColor
,
...
...
@@ -1319,6 +1319,7 @@ class RawChip extends StatefulWidget
this
.
avatarBorder
=
const
CircleBorder
(),
})
:
assert
(
label
!=
null
),
assert
(
isEnabled
!=
null
),
assert
(
selected
!=
null
),
assert
(
clipBehavior
!=
null
),
assert
(
pressElevation
==
null
||
pressElevation
>=
0.0
),
assert
(
elevation
==
null
||
elevation
>=
0.0
),
...
...
@@ -1430,7 +1431,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
assert
(
widget
.
onSelected
==
null
||
widget
.
onPressed
==
null
);
super
.
initState
();
_updateState
(
MaterialState
.
disabled
,
!
widget
.
isEnabled
);
_updateState
(
MaterialState
.
selected
,
widget
.
selected
??
false
);
_updateState
(
MaterialState
.
selected
,
widget
.
selected
);
selectController
=
AnimationController
(
duration:
_kSelectDuration
,
value:
widget
.
selected
==
true
?
1.0
:
0.0
,
...
...
@@ -1588,7 +1589,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
}
if
(
oldWidget
.
selected
!=
widget
.
selected
)
{
setState
(()
{
_updateState
(
MaterialState
.
selected
,
widget
.
selected
??
false
);
_updateState
(
MaterialState
.
selected
,
widget
.
selected
);
if
(
widget
.
selected
==
true
)
{
selectController
.
forward
();
}
else
{
...
...
@@ -1655,7 +1656,6 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
final
double
pressElevation
=
widget
.
pressElevation
??
chipTheme
.
pressElevation
??
_defaultPressElevation
;
final
Color
shadowColor
=
widget
.
shadowColor
??
chipTheme
.
shadowColor
??
_defaultShadowColor
;
final
Color
selectedShadowColor
=
widget
.
selectedShadowColor
??
chipTheme
.
selectedShadowColor
??
_defaultShadowColor
;
final
bool
selected
=
widget
.
selected
??
false
;
final
TextStyle
effectiveLabelStyle
=
widget
.
labelStyle
??
chipTheme
.
labelStyle
;
final
Color
resolvedLabelColor
=
MaterialStateProperty
.
resolveAs
<
Color
>(
effectiveLabelStyle
?.
color
,
_states
);
...
...
@@ -1665,7 +1665,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
onFocusChange:
_handleFocus
,
child:
Material
(
elevation:
isTapping
?
pressElevation
:
elevation
,
shadowColor:
selected
?
selectedShadowColor
:
shadowColor
,
shadowColor:
widget
.
selected
?
selectedShadowColor
:
shadowColor
,
animationDuration:
pressedAnimationDuration
,
shape:
shape
,
clipBehavior:
widget
.
clipBehavior
,
...
...
packages/flutter/test/material/chip_test.dart
View file @
17ddfb1b
...
...
@@ -1168,7 +1168,7 @@ void main() {
deleteIcon:
deleteIcon
,
isEnabled:
isSelectable
||
isPressable
,
shape:
chipTheme
.
shape
,
selected:
isSelectable
?
value
:
null
,
selected:
isSelectable
&&
value
,
label:
Text
(
'
$value
'
),
onSelected:
isSelectable
?
(
bool
newValue
)
{
...
...
@@ -1738,6 +1738,20 @@ void main() {
expect
(
find
.
byType
(
InkWell
),
findsOneWidget
);
});
testWidgets
(
'RawChip.selected can not be null'
,
(
WidgetTester
tester
)
async
{
expect
(()
async
{
MaterialApp
(
home:
Material
(
child:
RawChip
(
onPressed:
()
{
},
selected:
null
,
label:
const
Text
(
'Chip'
),
),
),
);
},
throwsAssertionError
);
});
testWidgets
(
'Chip uses stateful color for text color in different states'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
focusNode
=
FocusNode
();
...
...
packages/flutter/test/material/chip_theme_test.dart
View file @
17ddfb1b
...
...
@@ -71,7 +71,6 @@ void main() {
backgroundColor:
Colors
.
blue
,
);
final
ChipThemeData
chipTheme
=
theme
.
chipTheme
;
bool
value
;
Widget
buildChip
(
ChipThemeData
data
)
{
return
MaterialApp
(
...
...
@@ -91,8 +90,8 @@ void main() {
avatar:
const
Placeholder
(),
deleteIcon:
const
Placeholder
(),
isEnabled:
true
,
selected:
valu
e
,
label:
Text
(
'
$value
'
),
selected:
fals
e
,
label:
const
Text
(
'Chip
'
),
onSelected:
(
bool
newValue
)
{
},
onPressed:
null
,
),
...
...
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