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
995aa138
Unverified
Commit
995aa138
authored
Dec 08, 2020
by
Ayush Bherwani
Committed by
GitHub
Dec 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ExpansionPanel] Exposes color property of MaterialSlice (#71657)
parent
ba988f8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
expansion_panel.dart
packages/flutter/lib/src/material/expansion_panel.dart
+8
-0
expansion_panel_test.dart
packages/flutter/test/material/expansion_panel_test.dart
+71
-0
No files found.
packages/flutter/lib/src/material/expansion_panel.dart
View file @
995aa138
...
...
@@ -78,6 +78,7 @@ class ExpansionPanel {
required
this
.
body
,
this
.
isExpanded
=
false
,
this
.
canTapOnHeader
=
false
,
this
.
backgroundColor
,
})
:
assert
(
headerBuilder
!=
null
),
assert
(
body
!=
null
),
assert
(
isExpanded
!=
null
),
...
...
@@ -101,6 +102,10 @@ class ExpansionPanel {
/// Defaults to false.
final
bool
canTapOnHeader
;
/// Defines the background color of the panel.
///
/// Defaults to [ThemeData.cardColor].
final
Color
?
backgroundColor
;
}
/// An expansion panel that allows for radio-like functionality.
...
...
@@ -123,11 +128,13 @@ class ExpansionPanelRadio extends ExpansionPanel {
required
ExpansionPanelHeaderBuilder
headerBuilder
,
required
Widget
body
,
bool
canTapOnHeader
=
false
,
Color
?
backgroundColor
,
})
:
assert
(
value
!=
null
),
super
(
body:
body
,
headerBuilder:
headerBuilder
,
canTapOnHeader:
canTapOnHeader
,
backgroundColor:
backgroundColor
,
);
/// The value that uniquely identifies a radio panel so that the currently
...
...
@@ -530,6 +537,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
items
.
add
(
MaterialSlice
(
key:
_SaltedKey
<
BuildContext
,
int
>(
context
,
index
*
2
),
color:
child
.
backgroundColor
,
child:
Column
(
children:
<
Widget
>[
header
,
...
...
packages/flutter/test/material/expansion_panel_test.dart
View file @
995aa138
...
...
@@ -1458,4 +1458,75 @@ void main() {
' possible elevation values.'
));
});
testWidgets
(
'ExpansionPanel.panelColor test'
,
(
WidgetTester
tester
)
async
{
const
Color
firstPanelColor
=
Colors
.
red
;
const
Color
secondPanelColor
=
Colors
.
brown
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
SingleChildScrollView
(
child:
ExpansionPanelList
(
expansionCallback:
(
int
_index
,
bool
_isExpanded
)
{},
children:
<
ExpansionPanel
>[
ExpansionPanel
(
backgroundColor:
firstPanelColor
,
headerBuilder:
(
BuildContext
context
,
bool
isExpanded
)
{
return
const
Text
(
'A'
);
},
body:
const
SizedBox
(
height:
100.0
),
),
ExpansionPanel
(
backgroundColor:
secondPanelColor
,
headerBuilder:
(
BuildContext
context
,
bool
isExpanded
)
{
return
const
Text
(
'B'
);
},
body:
const
SizedBox
(
height:
100.0
),
),
],
),
),
),
);
final
MergeableMaterial
mergeableMaterial
=
tester
.
widget
(
find
.
byType
(
MergeableMaterial
));
expect
((
mergeableMaterial
.
children
.
first
as
MaterialSlice
).
color
,
firstPanelColor
);
expect
((
mergeableMaterial
.
children
.
last
as
MaterialSlice
).
color
,
secondPanelColor
);
});
testWidgets
(
'ExpansionPanelRadio.backgroundColor test'
,
(
WidgetTester
tester
)
async
{
const
Color
firstPanelColor
=
Colors
.
red
;
const
Color
secondPanelColor
=
Colors
.
brown
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
SingleChildScrollView
(
child:
ExpansionPanelList
.
radio
(
children:
<
ExpansionPanelRadio
>[
ExpansionPanelRadio
(
backgroundColor:
firstPanelColor
,
headerBuilder:
(
BuildContext
context
,
bool
isExpanded
)
{
return
const
Text
(
'A'
);
},
body:
const
SizedBox
(
height:
100.0
),
value:
0
,
),
ExpansionPanelRadio
(
backgroundColor:
secondPanelColor
,
headerBuilder:
(
BuildContext
context
,
bool
isExpanded
)
{
return
const
Text
(
'B'
);
},
body:
const
SizedBox
(
height:
100.0
),
value:
1
,
),
],
),
),
));
final
MergeableMaterial
mergeableMaterial
=
tester
.
widget
(
find
.
byType
(
MergeableMaterial
));
expect
((
mergeableMaterial
.
children
.
first
as
MaterialSlice
).
color
,
firstPanelColor
);
expect
((
mergeableMaterial
.
children
.
last
as
MaterialSlice
).
color
,
secondPanelColor
);
});
}
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