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
be5a8429
Unverified
Commit
be5a8429
authored
Apr 04, 2023
by
Rydmike
Committed by
GitHub
Apr 04, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX: SegmentedButton segments background cannot be made transparent (#123293)
parent
37d4e7d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
segmented_button.dart
packages/flutter/lib/src/material/segmented_button.dart
+1
-0
segmented_button_test.dart
packages/flutter/test/material/segmented_button_test.dart
+29
-0
No files found.
packages/flutter/lib/src/material/segmented_button.dart
View file @
be5a8429
...
@@ -354,6 +354,7 @@ class SegmentedButton<T> extends StatelessWidget {
...
@@ -354,6 +354,7 @@ class SegmentedButton<T> extends StatelessWidget {
final
List
<
Widget
>
buttons
=
segments
.
map
(
buttonFor
).
toList
();
final
List
<
Widget
>
buttons
=
segments
.
map
(
buttonFor
).
toList
();
return
Material
(
return
Material
(
type:
MaterialType
.
transparency
,
shape:
enabledBorder
.
copyWith
(
side:
BorderSide
.
none
),
shape:
enabledBorder
.
copyWith
(
side:
BorderSide
.
none
),
elevation:
resolve
<
double
?>((
ButtonStyle
?
style
)
=>
style
?.
elevation
)!,
elevation:
resolve
<
double
?>((
ButtonStyle
?
style
)
=>
style
?.
elevation
)!,
shadowColor:
resolve
<
Color
?>((
ButtonStyle
?
style
)
=>
style
?.
shadowColor
),
shadowColor:
resolve
<
Color
?>((
ButtonStyle
?
style
)
=>
style
?.
shadowColor
),
...
...
packages/flutter/test/material/segmented_button_test.dart
View file @
be5a8429
...
@@ -19,6 +19,35 @@ Widget boilerplate({required Widget child}) {
...
@@ -19,6 +19,35 @@ Widget boilerplate({required Widget child}) {
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'SegmentedButton is built with Material of type MaterialType.transparency'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
theme
=
ThemeData
(
useMaterial3:
true
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
theme
,
home:
Scaffold
(
body:
Center
(
child:
SegmentedButton
<
int
>(
segments:
const
<
ButtonSegment
<
int
>>[
ButtonSegment
<
int
>(
value:
1
,
label:
Text
(
'1'
)),
ButtonSegment
<
int
>(
value:
2
,
label:
Text
(
'2'
)),
ButtonSegment
<
int
>(
value:
3
,
label:
Text
(
'3'
),
enabled:
false
),
],
selected:
const
<
int
>{
2
},
onSelectionChanged:
(
Set
<
int
>
selected
)
{
},
),
),
),
),
);
// Expect SegmentedButton to be built with type MaterialType.transparency.
final
Finder
text
=
find
.
text
(
'1'
);
final
Finder
parent
=
find
.
ancestor
(
of:
text
,
matching:
find
.
byType
(
Material
)).
first
;
final
Finder
parentMaterial
=
find
.
ancestor
(
of:
parent
,
matching:
find
.
byType
(
Material
)).
first
;
final
Material
material
=
tester
.
widget
<
Material
>(
parentMaterial
);
expect
(
material
.
type
,
MaterialType
.
transparency
);
});
testWidgets
(
'SegmentedButton supports exclusive choice by default'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'SegmentedButton supports exclusive choice by default'
,
(
WidgetTester
tester
)
async
{
int
callbackCount
=
0
;
int
callbackCount
=
0
;
int
selectedSegment
=
2
;
int
selectedSegment
=
2
;
...
...
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