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
789d668e
Unverified
Commit
789d668e
authored
Oct 17, 2022
by
Darren Austin
Committed by
GitHub
Oct 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added statesController to the button icon constructors. (#113419)
parent
e93297b9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
147 additions
and
52 deletions
+147
-52
elevated_button.dart
packages/flutter/lib/src/material/elevated_button.dart
+2
-0
filled_button.dart
packages/flutter/lib/src/material/filled_button.dart
+5
-0
outlined_button.dart
packages/flutter/lib/src/material/outlined_button.dart
+2
-0
text_button.dart
packages/flutter/lib/src/material/text_button.dart
+2
-0
elevated_button_test.dart
packages/flutter/test/material/elevated_button_test.dart
+34
-12
filled_button_test.dart
packages/flutter/test/material/filled_button_test.dart
+34
-12
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+34
-14
text_button_test.dart
packages/flutter/test/material/text_button_test.dart
+34
-14
No files found.
packages/flutter/lib/src/material/elevated_button.dart
View file @
789d668e
...
...
@@ -95,6 +95,7 @@ class ElevatedButton extends ButtonStyleButton {
FocusNode
?
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
MaterialStatesController
?
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
=
_ElevatedButtonWithIcon
;
...
...
@@ -482,6 +483,7 @@ class _ElevatedButtonWithIcon extends ElevatedButton {
super
.
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
super
.
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
:
assert
(
icon
!=
null
),
...
...
packages/flutter/lib/src/material/filled_button.dart
View file @
789d668e
...
...
@@ -96,6 +96,7 @@ class FilledButton extends ButtonStyleButton {
FocusNode
?
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
MaterialStatesController
?
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
=
_FilledButtonWithIcon
;
...
...
@@ -138,6 +139,7 @@ class FilledButton extends ButtonStyleButton {
FocusNode
?
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
MaterialStatesController
?
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
{
...
...
@@ -151,6 +153,7 @@ class FilledButton extends ButtonStyleButton {
focusNode:
focusNode
,
autofocus:
autofocus
,
clipBehavior:
clipBehavior
,
statesController:
statesController
,
icon:
icon
,
label:
label
,
);
...
...
@@ -430,6 +433,7 @@ class _FilledButtonWithIcon extends FilledButton {
super
.
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
super
.
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
:
assert
(
icon
!=
null
),
...
...
@@ -450,6 +454,7 @@ class _FilledButtonWithIcon extends FilledButton {
super
.
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
super
.
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
:
assert
(
icon
!=
null
),
...
...
packages/flutter/lib/src/material/outlined_button.dart
View file @
789d668e
...
...
@@ -98,6 +98,7 @@ class OutlinedButton extends ButtonStyleButton {
FocusNode
?
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
MaterialStatesController
?
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
=
_OutlinedButtonWithIcon
;
...
...
@@ -413,6 +414,7 @@ class _OutlinedButtonWithIcon extends OutlinedButton {
super
.
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
super
.
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
:
assert
(
icon
!=
null
),
...
...
packages/flutter/lib/src/material/text_button.dart
View file @
789d668e
...
...
@@ -107,6 +107,7 @@ class TextButton extends ButtonStyleButton {
FocusNode
?
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
MaterialStatesController
?
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
=
_TextButtonWithIcon
;
...
...
@@ -448,6 +449,7 @@ class _TextButtonWithIcon extends TextButton {
super
.
focusNode
,
bool
?
autofocus
,
Clip
?
clipBehavior
,
super
.
statesController
,
required
Widget
icon
,
required
Widget
label
,
})
:
assert
(
icon
!=
null
),
...
...
packages/flutter/test/material/elevated_button_test.dart
View file @
789d668e
...
...
@@ -1624,7 +1624,7 @@ void main() {
expect
(
material
.
textStyle
!.
color
,
Colors
.
white
);
});
testWidgets
(
'ElevatedButton statesController'
,
(
WidgetTester
tester
)
async
{
Future
<
void
>
testStatesController
(
Widget
?
icon
,
WidgetTester
tester
)
async
{
int
count
=
0
;
void
valueChanged
()
{
count
+=
1
;
...
...
@@ -1635,11 +1635,18 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
ElevatedButton
(
statesController:
controller
,
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
child:
icon
==
null
?
ElevatedButton
(
statesController:
controller
,
onPressed:
()
{
},
child:
const
Text
(
'button'
),
)
:
ElevatedButton
.
icon
(
statesController:
controller
,
onPressed:
()
{
},
icon:
icon
,
label:
const
Text
(
'button'
),
),
),
),
);
...
...
@@ -1647,7 +1654,7 @@ void main() {
expect
(
controller
.
value
,
<
MaterialState
>{});
expect
(
count
,
0
);
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
ElevatedButton
));
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
Text
));
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
);
...
...
@@ -1698,11 +1705,18 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
ElevatedButton
(
statesController:
controller
,
onPressed:
null
,
child:
const
Text
(
'button'
),
),
child:
icon
==
null
?
ElevatedButton
(
statesController:
controller
,
onPressed:
null
,
child:
const
Text
(
'button'
),
)
:
ElevatedButton
.
icon
(
statesController:
controller
,
onPressed:
null
,
icon:
icon
,
label:
const
Text
(
'button'
),
),
),
),
);
...
...
@@ -1714,6 +1728,14 @@ void main() {
expect
(
controller
.
value
,
<
MaterialState
>{
MaterialState
.
disabled
});
expect
(
count
,
11
);
await
gesture
.
removePointer
();
}
testWidgets
(
'ElevatedButton statesController'
,
(
WidgetTester
tester
)
async
{
testStatesController
(
null
,
tester
);
});
testWidgets
(
'ElevatedButton.icon statesController'
,
(
WidgetTester
tester
)
async
{
testStatesController
(
const
Icon
(
Icons
.
add
),
tester
);
});
testWidgets
(
'Disabled ElevatedButton statesController'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/filled_button_test.dart
View file @
789d668e
...
...
@@ -1628,7 +1628,7 @@ void main() {
expect
(
material
.
textStyle
!.
color
,
Colors
.
white
);
});
testWidgets
(
'FilledButton statesController'
,
(
WidgetTester
tester
)
async
{
Future
<
void
>
testStatesController
(
Widget
?
icon
,
WidgetTester
tester
)
async
{
int
count
=
0
;
void
valueChanged
()
{
count
+=
1
;
...
...
@@ -1639,11 +1639,18 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
FilledButton
(
statesController:
controller
,
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
child:
icon
==
null
?
FilledButton
(
statesController:
controller
,
onPressed:
()
{
},
child:
const
Text
(
'button'
),
)
:
FilledButton
.
icon
(
statesController:
controller
,
onPressed:
()
{
},
icon:
icon
,
label:
const
Text
(
'button'
),
),
),
),
);
...
...
@@ -1651,7 +1658,7 @@ void main() {
expect
(
controller
.
value
,
<
MaterialState
>{});
expect
(
count
,
0
);
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
FilledButton
));
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
Text
));
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
);
...
...
@@ -1702,11 +1709,18 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
FilledButton
(
statesController:
controller
,
onPressed:
null
,
child:
const
Text
(
'button'
),
),
child:
icon
==
null
?
FilledButton
(
statesController:
controller
,
onPressed:
null
,
child:
const
Text
(
'button'
),
)
:
FilledButton
.
icon
(
statesController:
controller
,
onPressed:
null
,
icon:
icon
,
label:
const
Text
(
'button'
),
),
),
),
);
...
...
@@ -1718,6 +1732,14 @@ void main() {
expect
(
controller
.
value
,
<
MaterialState
>{
MaterialState
.
disabled
});
expect
(
count
,
11
);
await
gesture
.
removePointer
();
}
testWidgets
(
'FilledButton statesController'
,
(
WidgetTester
tester
)
async
{
testStatesController
(
null
,
tester
);
});
testWidgets
(
'FilledButton.icon statesController'
,
(
WidgetTester
tester
)
async
{
testStatesController
(
const
Icon
(
Icons
.
add
),
tester
);
});
testWidgets
(
'Disabled FilledButton statesController'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/outlined_button_test.dart
View file @
789d668e
...
...
@@ -1742,7 +1742,7 @@ void main() {
expect
(
material
.
textStyle
!.
color
,
Colors
.
white
);
});
testWidgets
(
'OutlinedButton statesController'
,
(
WidgetTester
tester
)
async
{
Future
<
void
>
testStatesController
(
Widget
?
icon
,
WidgetTester
tester
)
async
{
int
count
=
0
;
void
valueChanged
()
{
count
+=
1
;
...
...
@@ -1753,11 +1753,18 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
OutlinedButton
(
statesController:
controller
,
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
child:
icon
==
null
?
OutlinedButton
(
statesController:
controller
,
onPressed:
()
{
},
child:
const
Text
(
'button'
),
)
:
OutlinedButton
.
icon
(
statesController:
controller
,
onPressed:
()
{
},
icon:
icon
,
label:
const
Text
(
'button'
),
),
),
),
);
...
...
@@ -1765,7 +1772,7 @@ void main() {
expect
(
controller
.
value
,
<
MaterialState
>{});
expect
(
count
,
0
);
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
OutlinedButton
));
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
Text
));
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
);
...
...
@@ -1816,24 +1823,37 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
OutlinedButton
(
statesController:
controller
,
onPressed:
null
,
child:
const
Text
(
'button'
),
),
child:
icon
==
null
?
OutlinedButton
(
statesController:
controller
,
onPressed:
null
,
child:
const
Text
(
'button'
),
)
:
OutlinedButton
.
icon
(
statesController:
controller
,
onPressed:
null
,
icon:
icon
,
label:
const
Text
(
'button'
),
),
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
controller
.
value
,
<
MaterialState
>{
MaterialState
.
hovered
,
MaterialState
.
disabled
});
expect
(
count
,
10
);
// removes pressed and adds disabled - two changes
await
gesture
.
moveTo
(
Offset
.
zero
);
await
tester
.
pumpAndSettle
();
expect
(
controller
.
value
,
<
MaterialState
>{
MaterialState
.
disabled
});
expect
(
count
,
11
);
await
gesture
.
removePointer
();
}
testWidgets
(
'OutlinedButton statesController'
,
(
WidgetTester
tester
)
async
{
testStatesController
(
null
,
tester
);
});
testWidgets
(
'OutlinedButton.icon statesController'
,
(
WidgetTester
tester
)
async
{
testStatesController
(
const
Icon
(
Icons
.
add
),
tester
);
});
testWidgets
(
'Disabled OutlinedButton statesController'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/text_button_test.dart
View file @
789d668e
...
...
@@ -1549,7 +1549,7 @@ void main() {
expect
(
material
.
textStyle
!.
color
,
Colors
.
white
);
});
testWidgets
(
'TextButton statesController'
,
(
WidgetTester
tester
)
async
{
Future
<
void
>
testStatesController
(
Widget
?
icon
,
WidgetTester
tester
)
async
{
int
count
=
0
;
void
valueChanged
()
{
count
+=
1
;
...
...
@@ -1560,11 +1560,18 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
TextButton
(
statesController:
controller
,
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
child:
icon
==
null
?
TextButton
(
statesController:
controller
,
onPressed:
()
{
},
child:
const
Text
(
'button'
),
)
:
TextButton
.
icon
(
statesController:
controller
,
onPressed:
()
{
},
icon:
icon
,
label:
const
Text
(
'button'
),
),
),
),
);
...
...
@@ -1572,7 +1579,7 @@ void main() {
expect
(
controller
.
value
,
<
MaterialState
>{});
expect
(
count
,
0
);
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
Text
Button
));
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
Text
));
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
);
...
...
@@ -1623,24 +1630,37 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
TextButton
(
statesController:
controller
,
onPressed:
null
,
child:
const
Text
(
'button'
),
),
child:
icon
==
null
?
TextButton
(
statesController:
controller
,
onPressed:
null
,
child:
const
Text
(
'button'
),
)
:
TextButton
.
icon
(
statesController:
controller
,
onPressed:
null
,
icon:
icon
,
label:
const
Text
(
'button'
),
),
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
controller
.
value
,
<
MaterialState
>{
MaterialState
.
hovered
,
MaterialState
.
disabled
});
expect
(
count
,
10
);
// removes pressed and adds disabled - two changes
await
gesture
.
moveTo
(
Offset
.
zero
);
await
tester
.
pumpAndSettle
();
expect
(
controller
.
value
,
<
MaterialState
>{
MaterialState
.
disabled
});
expect
(
count
,
11
);
await
gesture
.
removePointer
();
}
testWidgets
(
'TextButton statesController'
,
(
WidgetTester
tester
)
async
{
testStatesController
(
null
,
tester
);
});
testWidgets
(
'TextButton.icon statesController'
,
(
WidgetTester
tester
)
async
{
testStatesController
(
const
Icon
(
Icons
.
add
),
tester
);
});
testWidgets
(
'Disabled TextButton statesController'
,
(
WidgetTester
tester
)
async
{
...
...
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