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
23cc1401
Unverified
Commit
23cc1401
authored
Nov 02, 2020
by
Hans Muller
Committed by
GitHub
Nov 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the button.icon factory constructors for NNBD (#69596)
parent
7d539043
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
150 additions
and
36 deletions
+150
-36
elevated_button.dart
packages/flutter/lib/src/material/elevated_button.dart
+7
-7
outlined_button.dart
packages/flutter/lib/src/material/outlined_button.dart
+7
-7
text_button.dart
packages/flutter/lib/src/material/text_button.dart
+7
-7
elevated_button_test.dart
packages/flutter/test/material/elevated_button_test.dart
+41
-5
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+51
-9
text_button_test.dart
packages/flutter/test/material/text_button_test.dart
+37
-1
No files found.
packages/flutter/lib/src/material/elevated_button.dart
View file @
23cc1401
...
...
@@ -82,13 +82,13 @@ class ElevatedButton extends ButtonStyleButton {
///
/// The [icon] and [label] arguments must not be null.
factory
ElevatedButton
.
icon
({
Key
key
,
required
VoidCallback
onPressed
,
VoidCallback
onLongPress
,
ButtonStyle
style
,
FocusNode
focusNode
,
bool
autofocus
,
Clip
clipBehavior
,
Key
?
key
,
required
VoidCallback
?
onPressed
,
VoidCallback
?
onLongPress
,
ButtonStyle
?
style
,
FocusNode
?
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
required
Widget
icon
,
required
Widget
label
,
})
=
_ElevatedButtonWithIcon
;
...
...
packages/flutter/lib/src/material/outlined_button.dart
View file @
23cc1401
...
...
@@ -79,13 +79,13 @@ class OutlinedButton extends ButtonStyleButton {
///
/// The [icon] and [label] arguments must not be null.
factory
OutlinedButton
.
icon
({
Key
key
,
required
VoidCallback
onPressed
,
VoidCallback
onLongPress
,
ButtonStyle
style
,
FocusNode
focusNode
,
bool
autofocus
,
Clip
clipBehavior
,
Key
?
key
,
required
VoidCallback
?
onPressed
,
VoidCallback
?
onLongPress
,
ButtonStyle
?
style
,
FocusNode
?
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
required
Widget
icon
,
required
Widget
label
,
})
=
_OutlinedButtonWithIcon
;
...
...
packages/flutter/lib/src/material/text_button.dart
View file @
23cc1401
...
...
@@ -86,13 +86,13 @@ class TextButton extends ButtonStyleButton {
///
/// The [icon] and [label] arguments must not be null.
factory
TextButton
.
icon
({
Key
key
,
required
VoidCallback
onPressed
,
VoidCallback
onLongPress
,
ButtonStyle
style
,
FocusNode
focusNode
,
bool
autofocus
,
Clip
clipBehavior
,
Key
?
key
,
required
VoidCallback
?
onPressed
,
VoidCallback
?
onLongPress
,
ButtonStyle
?
style
,
FocusNode
?
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
required
Widget
icon
,
required
Widget
label
,
})
=
_TextButtonWithIcon
;
...
...
packages/flutter/test/material/elevated_button_test.dart
View file @
23cc1401
...
...
@@ -11,7 +11,7 @@ import '../rendering/mock_canvas.dart';
import
'../widgets/semantics_tester.dart'
;
void
main
(
)
{
testWidgets
(
'ElevatedButton defaults'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ElevatedButton
, ElevatedButton.icon
defaults'
,
(
WidgetTester
tester
)
async
{
const
ColorScheme
colorScheme
=
ColorScheme
.
light
();
// Enabled ElevatedButton
...
...
@@ -27,13 +27,13 @@ void main() {
),
);
final
Finder
rawB
uttonMaterial
=
find
.
descendant
(
final
Finder
b
uttonMaterial
=
find
.
descendant
(
of:
find
.
byType
(
ElevatedButton
),
matching:
find
.
byType
(
Material
),
);
Material
material
=
tester
.
widget
<
Material
>(
rawB
uttonMaterial
);
Material
material
=
tester
.
widget
<
Material
>(
b
uttonMaterial
);
expect
(
material
.
animationDuration
,
const
Duration
(
milliseconds:
200
));
expect
(
material
.
borderOnForeground
,
true
);
expect
(
material
.
borderRadius
,
null
);
...
...
@@ -56,7 +56,7 @@ void main() {
expect
(
inkFeatures
,
paints
..
circle
(
color:
colorScheme
.
onPrimary
.
withAlpha
(
0x3d
)));
// splash color is onPrimary(0.24)
// Only elevation changes when enabled and pressed.
material
=
tester
.
widget
<
Material
>(
rawB
uttonMaterial
);
material
=
tester
.
widget
<
Material
>(
b
uttonMaterial
);
expect
(
material
.
animationDuration
,
const
Duration
(
milliseconds:
200
));
expect
(
material
.
borderOnForeground
,
true
);
expect
(
material
.
borderRadius
,
null
);
...
...
@@ -74,6 +74,42 @@ void main() {
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
// Enabled ElevatedButton.icon
final
Key
iconButtonKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
.
from
(
colorScheme:
colorScheme
),
home:
Center
(
child:
ElevatedButton
.
icon
(
key:
iconButtonKey
,
onPressed:
()
{
},
icon:
const
Icon
(
Icons
.
add
),
label:
const
Text
(
'label'
),
),
),
),
);
final
Finder
iconButtonMaterial
=
find
.
descendant
(
of:
find
.
byKey
(
iconButtonKey
),
matching:
find
.
byType
(
Material
),
);
material
=
tester
.
widget
<
Material
>(
iconButtonMaterial
);
expect
(
material
.
animationDuration
,
const
Duration
(
milliseconds:
200
));
expect
(
material
.
borderOnForeground
,
true
);
expect
(
material
.
borderRadius
,
null
);
expect
(
material
.
clipBehavior
,
Clip
.
none
);
expect
(
material
.
color
,
colorScheme
.
primary
);
expect
(
material
.
elevation
,
2
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4
)));
expect
(
material
.
textStyle
!.
color
,
colorScheme
.
onPrimary
);
expect
(
material
.
textStyle
!.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!.
fontSize
,
14
);
expect
(
material
.
textStyle
!.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
// Disabled ElevatedButton
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -90,7 +126,7 @@ void main() {
// Finish the elevation animation, final background color change.
await
tester
.
pumpAndSettle
();
material
=
tester
.
widget
<
Material
>(
rawB
uttonMaterial
);
material
=
tester
.
widget
<
Material
>(
b
uttonMaterial
);
expect
(
material
.
animationDuration
,
const
Duration
(
milliseconds:
200
));
expect
(
material
.
borderOnForeground
,
true
);
expect
(
material
.
borderRadius
,
null
);
...
...
packages/flutter/test/material/outlined_button_test.dart
View file @
23cc1401
...
...
@@ -11,12 +11,7 @@ import '../rendering/mock_canvas.dart';
import
'../widgets/semantics_tester.dart'
;
void
main
(
)
{
testWidgets
(
'OutlinedButton defaults'
,
(
WidgetTester
tester
)
async
{
final
Finder
rawButtonMaterial
=
find
.
descendant
(
of:
find
.
byType
(
OutlinedButton
),
matching:
find
.
byType
(
Material
),
);
testWidgets
(
'OutlinedButton, OutlinedButton.icon defaults'
,
(
WidgetTester
tester
)
async
{
const
ColorScheme
colorScheme
=
ColorScheme
.
light
();
// Enabled OutlinedButton
...
...
@@ -32,7 +27,12 @@ void main() {
),
);
Material
material
=
tester
.
widget
<
Material
>(
rawButtonMaterial
);
final
Finder
buttonMaterial
=
find
.
descendant
(
of:
find
.
byType
(
OutlinedButton
),
matching:
find
.
byType
(
Material
),
);
Material
material
=
tester
.
widget
<
Material
>(
buttonMaterial
);
expect
(
material
.
animationDuration
,
const
Duration
(
milliseconds:
200
));
expect
(
material
.
borderOnForeground
,
true
);
expect
(
material
.
borderRadius
,
null
);
...
...
@@ -63,7 +63,49 @@ void main() {
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
// No change vs enabled and not pressed.
material
=
tester
.
widget
<
Material
>(
rawButtonMaterial
);
material
=
tester
.
widget
<
Material
>(
buttonMaterial
);
expect
(
material
.
animationDuration
,
const
Duration
(
milliseconds:
200
));
expect
(
material
.
borderOnForeground
,
true
);
expect
(
material
.
borderRadius
,
null
);
expect
(
material
.
clipBehavior
,
Clip
.
none
);
expect
(
material
.
color
,
Colors
.
transparent
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
side:
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
),
),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
textStyle
!.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!.
fontSize
,
14
);
expect
(
material
.
textStyle
!.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
// Enabled OutlinedButton.icon
final
Key
iconButtonKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
.
from
(
colorScheme:
colorScheme
),
home:
Center
(
child:
OutlinedButton
.
icon
(
key:
iconButtonKey
,
onPressed:
()
{
},
icon:
const
Icon
(
Icons
.
add
),
label:
const
Text
(
'label'
),
),
),
),
);
final
Finder
iconButtonMaterial
=
find
.
descendant
(
of:
find
.
byKey
(
iconButtonKey
),
matching:
find
.
byType
(
Material
),
);
material
=
tester
.
widget
<
Material
>(
iconButtonMaterial
);
expect
(
material
.
animationDuration
,
const
Duration
(
milliseconds:
200
));
expect
(
material
.
borderOnForeground
,
true
);
expect
(
material
.
borderRadius
,
null
);
...
...
@@ -97,7 +139,7 @@ void main() {
),
);
material
=
tester
.
widget
<
Material
>(
rawB
uttonMaterial
);
material
=
tester
.
widget
<
Material
>(
b
uttonMaterial
);
expect
(
material
.
animationDuration
,
const
Duration
(
milliseconds:
200
));
expect
(
material
.
borderOnForeground
,
true
);
expect
(
material
.
borderRadius
,
null
);
...
...
packages/flutter/test/material/text_button_test.dart
View file @
23cc1401
...
...
@@ -11,7 +11,7 @@ import '../rendering/mock_canvas.dart';
import
'../widgets/semantics_tester.dart'
;
void
main
(
)
{
testWidgets
(
'TextButton defaults'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'TextButton
, TextButton.icon
defaults'
,
(
WidgetTester
tester
)
async
{
const
ColorScheme
colorScheme
=
ColorScheme
.
light
();
// Enabled TextButton
...
...
@@ -72,6 +72,42 @@ void main() {
expect
(
material
.
textStyle
!.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
// Enabled TextButton.icon
final
Key
iconButtonKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
.
from
(
colorScheme:
colorScheme
),
home:
Center
(
child:
TextButton
.
icon
(
key:
iconButtonKey
,
onPressed:
()
{
},
icon:
const
Icon
(
Icons
.
add
),
label:
const
Text
(
'label'
),
),
),
),
);
final
Finder
iconButtonMaterial
=
find
.
descendant
(
of:
find
.
byKey
(
iconButtonKey
),
matching:
find
.
byType
(
Material
),
);
material
=
tester
.
widget
<
Material
>(
iconButtonMaterial
);
expect
(
material
.
animationDuration
,
const
Duration
(
milliseconds:
200
));
expect
(
material
.
borderOnForeground
,
true
);
expect
(
material
.
borderRadius
,
null
);
expect
(
material
.
clipBehavior
,
Clip
.
none
);
expect
(
material
.
color
,
Colors
.
transparent
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4.0
)));
expect
(
material
.
textStyle
!.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!.
fontSize
,
14
);
expect
(
material
.
textStyle
!.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
// Disabled TextButton
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
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