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
14b8194b
Unverified
Commit
14b8194b
authored
Mar 16, 2021
by
Hans Muller
Committed by
GitHub
Mar 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added iconColor and textColor properties to ExpansionTile (#78281)
parent
7dc82828
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
7 deletions
+77
-7
expansion_tile.dart
packages/flutter/lib/src/material/expansion_tile.dart
+39
-7
expansion_tile_test.dart
packages/flutter/test/material/expansion_tile_test.dart
+38
-0
No files found.
packages/flutter/lib/src/material/expansion_tile.dart
View file @
14b8194b
...
@@ -20,12 +20,17 @@ const Duration _kExpand = Duration(milliseconds: 200);
...
@@ -20,12 +20,17 @@ const Duration _kExpand = Duration(milliseconds: 200);
/// [ExpansionTile] to save and restore its expanded state when it is scrolled
/// [ExpansionTile] to save and restore its expanded state when it is scrolled
/// in and out of view.
/// in and out of view.
///
///
/// This class overrides the [ListTileTheme.iconColor] and [ListTileTheme.textColor]
/// theme properties for its [ListTile]. These colors animate between values when
/// the tile is expanded and collapsed: between [iconColor], [collapsedIconColor] and
/// between [textColor] and [collapsedTextColor].
///
/// See also:
/// See also:
///
///
/// * [ListTile], useful for creating expansion tile [children] when the
/// * [ListTile], useful for creating expansion tile [children] when the
/// expansion tile represents a sublist.
/// expansion tile represents a sublist.
/// * The "Expand
/
collapse" section of
/// * The "Expand
and
collapse" section of
/// <https://material.io/components/lists#types>
.
/// <https://material.io/components/lists#types>
class
ExpansionTile
extends
StatefulWidget
{
class
ExpansionTile
extends
StatefulWidget
{
/// Creates a single-line [ListTile] with a trailing button that expands or collapses
/// Creates a single-line [ListTile] with a trailing button that expands or collapses
/// the tile to reveal or hide the [children]. The [initiallyExpanded] property must
/// the tile to reveal or hide the [children]. The [initiallyExpanded] property must
...
@@ -35,7 +40,6 @@ class ExpansionTile extends StatefulWidget {
...
@@ -35,7 +40,6 @@ class ExpansionTile extends StatefulWidget {
this
.
leading
,
this
.
leading
,
required
this
.
title
,
required
this
.
title
,
this
.
subtitle
,
this
.
subtitle
,
this
.
backgroundColor
,
this
.
onExpansionChanged
,
this
.
onExpansionChanged
,
this
.
children
=
const
<
Widget
>[],
this
.
children
=
const
<
Widget
>[],
this
.
trailing
,
this
.
trailing
,
...
@@ -45,7 +49,12 @@ class ExpansionTile extends StatefulWidget {
...
@@ -45,7 +49,12 @@ class ExpansionTile extends StatefulWidget {
this
.
expandedCrossAxisAlignment
,
this
.
expandedCrossAxisAlignment
,
this
.
expandedAlignment
,
this
.
expandedAlignment
,
this
.
childrenPadding
,
this
.
childrenPadding
,
this
.
backgroundColor
,
this
.
collapsedBackgroundColor
,
this
.
collapsedBackgroundColor
,
this
.
textColor
,
this
.
collapsedTextColor
,
this
.
iconColor
,
this
.
collapsedIconColor
,
})
:
assert
(
initiallyExpanded
!=
null
),
})
:
assert
(
initiallyExpanded
!=
null
),
assert
(
maintainState
!=
null
),
assert
(
maintainState
!=
null
),
assert
(
assert
(
...
@@ -147,6 +156,29 @@ class ExpansionTile extends StatefulWidget {
...
@@ -147,6 +156,29 @@ class ExpansionTile extends StatefulWidget {
/// When the value is null, the value of `childrenPadding` is [EdgeInsets.zero].
/// When the value is null, the value of `childrenPadding` is [EdgeInsets.zero].
final
EdgeInsetsGeometry
?
childrenPadding
;
final
EdgeInsetsGeometry
?
childrenPadding
;
/// The icon color of tile's [trailing] expansion icon when the
/// sublist is expanded.
///
/// Used to override to the [ListTileTheme.iconColor].
final
Color
?
iconColor
;
/// The icon color of tile's [trailing] expansion icon when the
/// sublist is collapsed.
///
/// Used to override to the [ListTileTheme.iconColor].
final
Color
?
collapsedIconColor
;
/// The color of the tile's titles when the sublist is expanded.
///
/// Used to override to the [ListTileTheme.textColor].
final
Color
?
textColor
;
/// The color of the tile's titles when the sublist is collapsed.
///
/// Used to override to the [ListTileTheme.textColor].
final
Color
?
collapsedTextColor
;
@override
@override
_ExpansionTileState
createState
()
=>
_ExpansionTileState
();
_ExpansionTileState
createState
()
=>
_ExpansionTileState
();
}
}
...
@@ -259,11 +291,11 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
...
@@ -259,11 +291,11 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
ThemeData
theme
=
Theme
.
of
(
context
);
_borderColorTween
.
end
=
theme
.
dividerColor
;
_borderColorTween
.
end
=
theme
.
dividerColor
;
_headerColorTween
_headerColorTween
..
begin
=
theme
.
textTheme
.
subtitle1
!.
color
..
begin
=
widget
.
collapsedTextColor
??
theme
.
textTheme
.
subtitle1
!.
color
..
end
=
theme
.
accentColor
;
..
end
=
widget
.
textColor
??
theme
.
accentColor
;
_iconColorTween
_iconColorTween
..
begin
=
theme
.
unselectedWidgetColor
..
begin
=
widget
.
collapsedIconColor
??
theme
.
unselectedWidgetColor
..
end
=
theme
.
accentColor
;
..
end
=
widget
.
iconColor
??
theme
.
accentColor
;
_backgroundColorTween
_backgroundColorTween
..
begin
=
widget
.
collapsedBackgroundColor
..
begin
=
widget
.
collapsedBackgroundColor
..
end
=
widget
.
backgroundColor
;
..
end
=
widget
.
backgroundColor
;
...
...
packages/flutter/test/material/expansion_tile_test.dart
View file @
14b8194b
...
@@ -520,4 +520,42 @@ void main() {
...
@@ -520,4 +520,42 @@ void main() {
expect
(
boxDecoration
.
color
,
backgroundColor
);
expect
(
boxDecoration
.
color
,
backgroundColor
);
});
});
testWidgets
(
'ExpansionTile iconColor, textColor'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/pull/78281
const
Color
iconColor
=
Color
(
0xff00ff00
);
const
Color
collapsedIconColor
=
Color
(
0xff0000ff
);
const
Color
textColor
=
Color
(
0xff00ffff
);
const
Color
collapsedTextColor
=
Color
(
0xffff00ff
);
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Material
(
child:
ExpansionTile
(
iconColor:
iconColor
,
collapsedIconColor:
collapsedIconColor
,
textColor:
textColor
,
collapsedTextColor:
collapsedTextColor
,
initiallyExpanded:
false
,
title:
TestText
(
'title'
),
trailing:
TestIcon
(),
children:
<
Widget
>[
SizedBox
(
height:
100
,
width:
100
),
],
),
),
));
Color
getIconColor
()
=>
tester
.
state
<
TestIconState
>(
find
.
byType
(
TestIcon
)).
iconTheme
.
color
!;
Color
getTextColor
()
=>
tester
.
state
<
TestTextState
>(
find
.
byType
(
TestText
)).
textStyle
.
color
!;
expect
(
getIconColor
(),
collapsedIconColor
);
expect
(
getTextColor
(),
collapsedTextColor
);
await
tester
.
tap
(
find
.
text
(
'title'
));
await
tester
.
pumpAndSettle
();
expect
(
getIconColor
(),
iconColor
);
expect
(
getTextColor
(),
textColor
);
});
}
}
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