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
Show 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
...
@@ -1285,8 +1285,8 @@ class RawChip extends StatefulWidget
/// The [onPressed] and [onSelected] callbacks must not both be specified at
/// The [onPressed] and [onSelected] callbacks must not both be specified at
/// the same time.
/// the same time.
///
///
/// The [label], [isEnabled],
and [clipBehavior] arguments must not be null.
/// The [label], [isEnabled],
[selected], and [clipBehavior] arguments must
/// The [pressElevation] and [elevation] must be null or non-negative.
///
not be null.
The [pressElevation] and [elevation] must be null or non-negative.
/// Typically, [pressElevation] is greater than [elevation].
/// Typically, [pressElevation] is greater than [elevation].
const
RawChip
({
const
RawChip
({
Key
key
,
Key
key
,
...
@@ -1303,7 +1303,7 @@ class RawChip extends StatefulWidget
...
@@ -1303,7 +1303,7 @@ class RawChip extends StatefulWidget
this
.
onSelected
,
this
.
onSelected
,
this
.
pressElevation
,
this
.
pressElevation
,
this
.
tapEnabled
=
true
,
this
.
tapEnabled
=
true
,
this
.
selected
,
this
.
selected
=
false
,
this
.
showCheckmark
=
true
,
this
.
showCheckmark
=
true
,
this
.
isEnabled
=
true
,
this
.
isEnabled
=
true
,
this
.
disabledColor
,
this
.
disabledColor
,
...
@@ -1319,6 +1319,7 @@ class RawChip extends StatefulWidget
...
@@ -1319,6 +1319,7 @@ class RawChip extends StatefulWidget
this
.
avatarBorder
=
const
CircleBorder
(),
this
.
avatarBorder
=
const
CircleBorder
(),
})
:
assert
(
label
!=
null
),
})
:
assert
(
label
!=
null
),
assert
(
isEnabled
!=
null
),
assert
(
isEnabled
!=
null
),
assert
(
selected
!=
null
),
assert
(
clipBehavior
!=
null
),
assert
(
clipBehavior
!=
null
),
assert
(
pressElevation
==
null
||
pressElevation
>=
0.0
),
assert
(
pressElevation
==
null
||
pressElevation
>=
0.0
),
assert
(
elevation
==
null
||
elevation
>=
0.0
),
assert
(
elevation
==
null
||
elevation
>=
0.0
),
...
@@ -1430,7 +1431,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
...
@@ -1430,7 +1431,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
assert
(
widget
.
onSelected
==
null
||
widget
.
onPressed
==
null
);
assert
(
widget
.
onSelected
==
null
||
widget
.
onPressed
==
null
);
super
.
initState
();
super
.
initState
();
_updateState
(
MaterialState
.
disabled
,
!
widget
.
isEnabled
);
_updateState
(
MaterialState
.
disabled
,
!
widget
.
isEnabled
);
_updateState
(
MaterialState
.
selected
,
widget
.
selected
??
false
);
_updateState
(
MaterialState
.
selected
,
widget
.
selected
);
selectController
=
AnimationController
(
selectController
=
AnimationController
(
duration:
_kSelectDuration
,
duration:
_kSelectDuration
,
value:
widget
.
selected
==
true
?
1.0
:
0.0
,
value:
widget
.
selected
==
true
?
1.0
:
0.0
,
...
@@ -1588,7 +1589,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
...
@@ -1588,7 +1589,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
}
}
if
(
oldWidget
.
selected
!=
widget
.
selected
)
{
if
(
oldWidget
.
selected
!=
widget
.
selected
)
{
setState
(()
{
setState
(()
{
_updateState
(
MaterialState
.
selected
,
widget
.
selected
??
false
);
_updateState
(
MaterialState
.
selected
,
widget
.
selected
);
if
(
widget
.
selected
==
true
)
{
if
(
widget
.
selected
==
true
)
{
selectController
.
forward
();
selectController
.
forward
();
}
else
{
}
else
{
...
@@ -1655,7 +1656,6 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
...
@@ -1655,7 +1656,6 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
final
double
pressElevation
=
widget
.
pressElevation
??
chipTheme
.
pressElevation
??
_defaultPressElevation
;
final
double
pressElevation
=
widget
.
pressElevation
??
chipTheme
.
pressElevation
??
_defaultPressElevation
;
final
Color
shadowColor
=
widget
.
shadowColor
??
chipTheme
.
shadowColor
??
_defaultShadowColor
;
final
Color
shadowColor
=
widget
.
shadowColor
??
chipTheme
.
shadowColor
??
_defaultShadowColor
;
final
Color
selectedShadowColor
=
widget
.
selectedShadowColor
??
chipTheme
.
selectedShadowColor
??
_defaultShadowColor
;
final
Color
selectedShadowColor
=
widget
.
selectedShadowColor
??
chipTheme
.
selectedShadowColor
??
_defaultShadowColor
;
final
bool
selected
=
widget
.
selected
??
false
;
final
TextStyle
effectiveLabelStyle
=
widget
.
labelStyle
??
chipTheme
.
labelStyle
;
final
TextStyle
effectiveLabelStyle
=
widget
.
labelStyle
??
chipTheme
.
labelStyle
;
final
Color
resolvedLabelColor
=
MaterialStateProperty
.
resolveAs
<
Color
>(
effectiveLabelStyle
?.
color
,
_states
);
final
Color
resolvedLabelColor
=
MaterialStateProperty
.
resolveAs
<
Color
>(
effectiveLabelStyle
?.
color
,
_states
);
...
@@ -1665,7 +1665,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
...
@@ -1665,7 +1665,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
onFocusChange:
_handleFocus
,
onFocusChange:
_handleFocus
,
child:
Material
(
child:
Material
(
elevation:
isTapping
?
pressElevation
:
elevation
,
elevation:
isTapping
?
pressElevation
:
elevation
,
shadowColor:
selected
?
selectedShadowColor
:
shadowColor
,
shadowColor:
widget
.
selected
?
selectedShadowColor
:
shadowColor
,
animationDuration:
pressedAnimationDuration
,
animationDuration:
pressedAnimationDuration
,
shape:
shape
,
shape:
shape
,
clipBehavior:
widget
.
clipBehavior
,
clipBehavior:
widget
.
clipBehavior
,
...
...
packages/flutter/test/material/chip_test.dart
View file @
17ddfb1b
...
@@ -1168,7 +1168,7 @@ void main() {
...
@@ -1168,7 +1168,7 @@ void main() {
deleteIcon:
deleteIcon
,
deleteIcon:
deleteIcon
,
isEnabled:
isSelectable
||
isPressable
,
isEnabled:
isSelectable
||
isPressable
,
shape:
chipTheme
.
shape
,
shape:
chipTheme
.
shape
,
selected:
isSelectable
?
value
:
null
,
selected:
isSelectable
&&
value
,
label:
Text
(
'
$value
'
),
label:
Text
(
'
$value
'
),
onSelected:
isSelectable
onSelected:
isSelectable
?
(
bool
newValue
)
{
?
(
bool
newValue
)
{
...
@@ -1738,6 +1738,20 @@ void main() {
...
@@ -1738,6 +1738,20 @@ void main() {
expect
(
find
.
byType
(
InkWell
),
findsOneWidget
);
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
{
testWidgets
(
'Chip uses stateful color for text color in different states'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
focusNode
=
FocusNode
();
final
FocusNode
focusNode
=
FocusNode
();
...
...
packages/flutter/test/material/chip_theme_test.dart
View file @
17ddfb1b
...
@@ -71,7 +71,6 @@ void main() {
...
@@ -71,7 +71,6 @@ void main() {
backgroundColor:
Colors
.
blue
,
backgroundColor:
Colors
.
blue
,
);
);
final
ChipThemeData
chipTheme
=
theme
.
chipTheme
;
final
ChipThemeData
chipTheme
=
theme
.
chipTheme
;
bool
value
;
Widget
buildChip
(
ChipThemeData
data
)
{
Widget
buildChip
(
ChipThemeData
data
)
{
return
MaterialApp
(
return
MaterialApp
(
...
@@ -91,8 +90,8 @@ void main() {
...
@@ -91,8 +90,8 @@ void main() {
avatar:
const
Placeholder
(),
avatar:
const
Placeholder
(),
deleteIcon:
const
Placeholder
(),
deleteIcon:
const
Placeholder
(),
isEnabled:
true
,
isEnabled:
true
,
selected:
valu
e
,
selected:
fals
e
,
label:
Text
(
'
$value
'
),
label:
const
Text
(
'Chip
'
),
onSelected:
(
bool
newValue
)
{
},
onSelected:
(
bool
newValue
)
{
},
onPressed:
null
,
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