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
49ff0d99
Unverified
Commit
49ff0d99
authored
Mar 08, 2021
by
Hans Muller
Committed by
GitHub
Mar 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed ListTile accentColor dependency (#77004)
parent
d39d4505
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
17 deletions
+58
-17
main.dart
dev/benchmarks/test_apps/stocks/lib/main.dart
+1
-1
icon_color_test.dart
dev/benchmarks/test_apps/stocks/test/icon_color_test.dart
+1
-1
list_tile.dart
packages/flutter/lib/src/material/list_tile.dart
+7
-15
list_tile_test.dart
packages/flutter/test/material/list_tile_test.dart
+49
-0
No files found.
dev/benchmarks/test_apps/stocks/lib/main.dart
View file @
49ff0d99
...
...
@@ -64,7 +64,7 @@ class StocksAppState extends State<StocksApp> {
case
StockMode
.
pessimistic
:
return
ThemeData
(
brightness:
Brightness
.
dark
,
accentColor:
Colors
.
redAccent
,
primarySwatch:
Colors
.
purple
,
);
}
assert
(
_configuration
.
stockMode
!=
null
);
...
...
dev/benchmarks/test_apps/stocks/test/icon_color_test.dart
View file @
49ff0d99
...
...
@@ -83,7 +83,7 @@ void main() {
await
tester
.
pump
(
const
Duration
(
seconds:
5
));
// end the transition
// check the color of the icon - dark mode
checkIconColor
(
tester
,
'Stock List'
,
Colors
.
redAccent
);
// theme accent
color
checkIconColor
(
tester
,
'Stock List'
,
Colors
.
purple
);
// theme primary
color
checkIconColor
(
tester
,
'Account Balance'
,
Colors
.
white38
);
// disabled
checkIconColor
(
tester
,
'About'
,
Colors
.
white
);
// enabled
});
...
...
packages/flutter/lib/src/material/list_tile.dart
View file @
49ff0d99
...
...
@@ -788,11 +788,6 @@ class ListTile extends StatelessWidget {
///
/// When [enabled] is false, the text color is set to [ThemeData.disabledColor].
///
/// When [selected] is true, the text color is set to [ListTileTheme.selectedColor]
/// if it's not null. If [ListTileTheme.selectedColor] is null, the text color
/// is set to [ThemeData.primaryColor] when [ThemeData.brightness] is
/// [Brightness.light] and to [ThemeData.accentColor] when it is [Brightness.dark].
///
/// When [selected] is false, the text color is set to [ListTileTheme.textColor]
/// if it's not null and to [TextTheme.caption]'s color if [ListTileTheme.textColor]
/// is null.
...
...
@@ -1019,9 +1014,11 @@ class ListTile extends StatelessWidget {
switch
(
theme
.
brightness
)
{
case
Brightness
.
light
:
return
selected
?
theme
.
primaryColor
:
Colors
.
black45
;
// For the sake of backwards compatibility, the default for unselected
// tiles is Colors.black45 rather than colorScheme.onSurface.withAlpha(0x73).
return
selected
?
theme
.
colorScheme
.
primary
:
Colors
.
black45
;
case
Brightness
.
dark
:
return
selected
?
theme
.
accentColor
:
null
;
// null - use current icon theme color
return
selected
?
theme
.
colorScheme
.
primary
:
null
;
// null - use current icon theme color
}
}
...
...
@@ -1035,14 +1032,9 @@ class ListTile extends StatelessWidget {
if
(!
selected
&&
tileTheme
?.
textColor
!=
null
)
return
tileTheme
!.
textColor
;
if
(
selected
)
{
switch
(
theme
.
brightness
)
{
case
Brightness
.
light
:
return
theme
.
primaryColor
;
case
Brightness
.
dark
:
return
theme
.
accentColor
;
}
}
if
(
selected
)
return
theme
.
colorScheme
.
primary
;
return
defaultColor
;
}
...
...
packages/flutter/test/material/list_tile_test.dart
View file @
49ff0d99
...
...
@@ -2284,4 +2284,53 @@ void main() {
expect
(
textColor
(
leadingKey
),
theme
.
disabledColor
);
expect
(
textColor
(
trailingKey
),
theme
.
disabledColor
);
});
testWidgets
(
'selected, enabled ListTile default icon color, light and dark themes'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/pull/77004
const
ColorScheme
lightColorScheme
=
ColorScheme
.
light
();
const
ColorScheme
darkColorScheme
=
ColorScheme
.
dark
();
final
Key
leadingKey
=
UniqueKey
();
final
Key
trailingKey
=
UniqueKey
();
Widget
buildFrame
({
required
Brightness
brightness
,
required
bool
selected
})
{
final
ThemeData
theme
=
brightness
==
Brightness
.
light
?
ThemeData
.
from
(
colorScheme:
const
ColorScheme
.
light
())
:
ThemeData
.
from
(
colorScheme:
const
ColorScheme
.
dark
());
return
MaterialApp
(
theme:
theme
,
home:
Material
(
child:
Center
(
child:
ListTile
(
enabled:
true
,
selected:
selected
,
leading:
TestIcon
(
key:
leadingKey
),
trailing:
TestIcon
(
key:
trailingKey
),
),
),
),
);
}
Color
iconColor
(
Key
key
)
=>
tester
.
state
<
TestIconState
>(
find
.
byKey
(
key
)).
iconTheme
.
color
!;
await
tester
.
pumpWidget
(
buildFrame
(
brightness:
Brightness
.
light
,
selected:
true
));
expect
(
iconColor
(
leadingKey
),
lightColorScheme
.
primary
);
expect
(
iconColor
(
trailingKey
),
lightColorScheme
.
primary
);
await
tester
.
pumpWidget
(
buildFrame
(
brightness:
Brightness
.
light
,
selected:
false
));
expect
(
iconColor
(
leadingKey
),
Colors
.
black45
);
expect
(
iconColor
(
trailingKey
),
Colors
.
black45
);
await
tester
.
pumpWidget
(
buildFrame
(
brightness:
Brightness
.
dark
,
selected:
true
));
await
tester
.
pumpAndSettle
();
// Animated theme change
expect
(
iconColor
(
leadingKey
),
darkColorScheme
.
primary
);
expect
(
iconColor
(
trailingKey
),
darkColorScheme
.
primary
);
// For this configuration, ListTile defers to the default IconTheme.
// The default dark theme's IconTheme has color:white
await
tester
.
pumpWidget
(
buildFrame
(
brightness:
Brightness
.
dark
,
selected:
false
));
expect
(
iconColor
(
leadingKey
),
Colors
.
white
);
expect
(
iconColor
(
trailingKey
),
Colors
.
white
);
});
}
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