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
0b216f7a
Unverified
Commit
0b216f7a
authored
Mar 31, 2022
by
Taha Tesser
Committed by
GitHub
Mar 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `ToggleButtons` (remove `RawMaterialButton`) (#99493)
parent
0e20a701
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
231 additions
and
460 deletions
+231
-460
toggle_buttons.dart
packages/flutter/lib/src/material/toggle_buttons.dart
+158
-415
toggle_buttons_test.dart
packages/flutter/test/material/toggle_buttons_test.dart
+58
-30
toggle_buttons_theme_test.dart
...ages/flutter/test/material/toggle_buttons_theme_test.dart
+15
-15
No files found.
packages/flutter/lib/src/material/toggle_buttons.dart
View file @
0b216f7a
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/toggle_buttons_test.dart
View file @
0b216f7a
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/toggle_buttons_theme_test.dart
View file @
0b216f7a
...
...
@@ -142,15 +142,15 @@ void main() {
TextStyle
textStyle
;
textStyle
=
tester
.
widget
<
DefaultTextStyle
>(
find
.
descendant
(
of:
find
.
widgetWithText
(
RawMaterial
Button
,
'First child'
),
matching:
find
.
byType
(
DefaultTextStyle
),
of:
find
.
widgetWithText
(
Text
Button
,
'First child'
),
matching:
find
.
byType
(
DefaultTextStyle
),
)).
style
;
expect
(
textStyle
.
textBaseline
,
TextBaseline
.
ideographic
);
expect
(
textStyle
.
fontSize
,
20.0
);
expect
(
textStyle
.
color
,
isNot
(
Colors
.
orange
));
textStyle
=
tester
.
widget
<
DefaultTextStyle
>(
find
.
descendant
(
of:
find
.
widgetWithText
(
RawMaterial
Button
,
'Second child'
),
of:
find
.
widgetWithText
(
Text
Button
,
'Second child'
),
matching:
find
.
byType
(
DefaultTextStyle
),
)).
style
;
expect
(
textStyle
.
textBaseline
,
TextBaseline
.
ideographic
);
...
...
@@ -171,6 +171,7 @@ void main() {
),
),
child:
ToggleButtons
(
tapTargetSize:
MaterialTapTargetSize
.
shrinkWrap
,
isSelected:
const
<
bool
>[
false
,
false
,
false
],
onPressed:
(
int
index
)
{},
children:
const
<
Widget
>[
...
...
@@ -184,13 +185,13 @@ void main() {
),
);
Rect
firstRect
=
tester
.
getRect
(
find
.
byType
(
RawMaterial
Button
).
at
(
0
));
Rect
firstRect
=
tester
.
getRect
(
find
.
byType
(
Text
Button
).
at
(
0
));
expect
(
firstRect
.
width
,
50.0
);
expect
(
firstRect
.
height
,
60.0
);
Rect
secondRect
=
tester
.
getRect
(
find
.
byType
(
RawMaterial
Button
).
at
(
1
));
Rect
secondRect
=
tester
.
getRect
(
find
.
byType
(
Text
Button
).
at
(
1
));
expect
(
secondRect
.
width
,
50.0
);
expect
(
secondRect
.
height
,
60.0
);
Rect
thirdRect
=
tester
.
getRect
(
find
.
byType
(
RawMaterial
Button
).
at
(
2
));
Rect
thirdRect
=
tester
.
getRect
(
find
.
byType
(
Text
Button
).
at
(
2
));
expect
(
thirdRect
.
width
,
50.0
);
expect
(
thirdRect
.
height
,
60.0
);
...
...
@@ -206,6 +207,7 @@ void main() {
),
),
child:
ToggleButtons
(
tapTargetSize:
MaterialTapTargetSize
.
shrinkWrap
,
isSelected:
const
<
bool
>[
false
,
false
,
false
],
onPressed:
(
int
index
)
{},
children:
const
<
Widget
>[
...
...
@@ -219,13 +221,13 @@ void main() {
),
);
firstRect
=
tester
.
getRect
(
find
.
byType
(
RawMaterial
Button
).
at
(
0
));
firstRect
=
tester
.
getRect
(
find
.
byType
(
Text
Button
).
at
(
0
));
expect
(
firstRect
.
width
,
20.0
);
expect
(
firstRect
.
height
,
10.0
);
secondRect
=
tester
.
getRect
(
find
.
byType
(
RawMaterial
Button
).
at
(
1
));
secondRect
=
tester
.
getRect
(
find
.
byType
(
Text
Button
).
at
(
1
));
expect
(
secondRect
.
width
,
20.0
);
expect
(
secondRect
.
height
,
10.0
);
thirdRect
=
tester
.
getRect
(
find
.
byType
(
RawMaterial
Button
).
at
(
2
));
thirdRect
=
tester
.
getRect
(
find
.
byType
(
Text
Button
).
at
(
2
));
expect
(
thirdRect
.
width
,
20.0
);
expect
(
thirdRect
.
height
,
10.0
);
});
...
...
@@ -235,13 +237,13 @@ void main() {
(
WidgetTester
tester
)
async
{
TextStyle
buttonTextStyle
(
String
text
)
{
return
tester
.
widget
<
DefaultTextStyle
>(
find
.
descendant
(
of:
find
.
widgetWithText
(
RawMaterial
Button
,
text
),
of:
find
.
widgetWithText
(
Text
Button
,
text
),
matching:
find
.
byType
(
DefaultTextStyle
),
)).
style
;
}
IconTheme
iconTheme
(
IconData
icon
)
{
return
tester
.
widget
(
find
.
descendant
(
of:
find
.
widgetWithIcon
(
RawMaterial
Button
,
icon
),
of:
find
.
widgetWithIcon
(
Text
Button
,
icon
),
matching:
find
.
byType
(
IconTheme
),
));
}
...
...
@@ -356,7 +358,7 @@ void main() {
);
final
Material
material
=
tester
.
widget
<
Material
>(
find
.
descendant
(
of:
find
.
byType
(
RawMaterial
Button
),
of:
find
.
byType
(
Text
Button
),
matching:
find
.
byType
(
Material
),
));
expect
(
material
.
color
,
customFillColor
);
...
...
@@ -367,7 +369,7 @@ void main() {
Material
buttonColor
(
String
text
)
{
return
tester
.
widget
<
Material
>(
find
.
descendant
(
of:
find
.
byType
(
RawMaterial
Button
),
of:
find
.
byType
(
Text
Button
),
matching:
find
.
widgetWithText
(
Material
,
text
),
),
);
...
...
@@ -476,7 +478,6 @@ void main() {
inkFeatures
,
paints
..
circle
(
color:
splashColor
)
..
rect
(
color:
highlightColor
),
);
await
touchGesture
.
up
();
...
...
@@ -507,7 +508,6 @@ void main() {
await
hoverGesture
.
removePointer
();
});
testWidgets
(
'Theme border width and border colors for enabled, selected and disabled states'
,
(
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