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
3cd58547
Commit
3cd58547
authored
Apr 02, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up and document icon button color logic
parent
285c696f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
icon.dart
packages/flutter/lib/src/material/icon.dart
+11
-0
icon_button.dart
packages/flutter/lib/src/material/icon_button.dart
+26
-2
No files found.
packages/flutter/lib/src/material/icon.dart
View file @
3cd58547
...
...
@@ -22,6 +22,11 @@ import 'theme.dart';
/// in your project's `flutter.yaml` file. This ensures that the
/// MaterialIcons font is included in your application. This font is
/// used to display the icons.
///
/// See also:
///
/// * [IconButton], for interactive icons
/// * [Icons], for the list of available icons for use with this class
class
Icon
extends
StatelessWidget
{
Icon
({
Key
key
,
...
...
@@ -41,6 +46,12 @@ class Icon extends StatelessWidget {
final
IconData
icon
;
/// The color to use when drawing the icon.
///
/// Defaults to the current [IconTheme] color, if any. If there is
/// no [IconTheme], then it defaults to white if the theme is dark
/// and black if the theme is light. See [Theme] to set the current
/// theme and [ThemeData.brightness] for setting the current theme's
/// brightness.
final
Color
color
;
Color
_getDefaultColorForThemeBrightness
(
ThemeBrightness
brightness
)
{
...
...
packages/flutter/lib/src/material/icon_button.dart
View file @
3cd58547
...
...
@@ -20,12 +20,18 @@ import 'tooltip.dart';
///
/// If the [onPressed] callback is not specified or null, then the button will
/// be disabled, will not react to touch.
///
/// See also:
///
/// * [Icons]
/// * [AppBar]
class
IconButton
extends
StatelessWidget
{
const
IconButton
({
Key
key
,
this
.
size
:
24.0
,
this
.
icon
,
this
.
color
,
this
.
disabledColor
,
this
.
onPressed
,
this
.
tooltip
})
:
super
(
key:
key
);
...
...
@@ -39,9 +45,22 @@ class IconButton extends StatelessWidget {
/// The icon to display inside the button.
final
IconData
icon
;
/// The color to use for the icon inside the button.
/// The color to use for the icon inside the button, if the icon is enabled.
/// Defaults to the current color, as defined by [Icon.color].
///
/// The icon is enabled if [onPressed] is not null.
///
/// See also [disabledColor].
final
Color
color
;
/// The color to use for the icon inside the button, if the icon is disabled.
/// Defaults to the [ThemeData.disabledColor] of the current [Theme].
///
/// The icon is disabled if [onPressed] is null.
///
/// See also [color].
final
Color
disabledColor
;
/// The callback that is invoked when the button is tapped or otherwise activated.
///
/// If this is set to null, the button will be disabled.
...
...
@@ -56,12 +75,17 @@ class IconButton extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterial
(
context
));
Color
currentColor
;
if
(
onPressed
!=
null
)
currentColor
=
color
;
else
currentColor
=
disabledColor
??
Theme
.
of
(
context
).
disabledColor
;
Widget
result
=
new
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
new
Icon
(
size:
size
,
icon:
icon
,
color:
onPressed
!=
null
?
color
:
Theme
.
of
(
context
).
disabled
Color
color:
current
Color
)
);
if
(
tooltip
!=
null
)
{
...
...
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