From a6532cc731b9fbf3212ecbf05f995b039010687e Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Thu, 21 Apr 2016 17:11:20 -0700 Subject: [PATCH] Remove IconThemeData.clampedOpacity (#3483) * Remove IconThemeData.clampedOpacity --- packages/flutter/lib/src/material/app_bar.dart | 2 +- packages/flutter/lib/src/material/icon.dart | 2 +- .../flutter/lib/src/material/icon_theme_data.dart | 13 ++++++------- packages/flutter/lib/src/material/popup_menu.dart | 1 + 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index 334e0c48a9..dfd569a341 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -191,7 +191,7 @@ class AppBar extends StatelessWidget { if (iconTheme != null) { iconTheme = new IconThemeData( - opacity: opacity * iconTheme.clampedOpacity, + opacity: opacity * iconTheme.opacity, color: iconTheme.color ); } diff --git a/packages/flutter/lib/src/material/icon.dart b/packages/flutter/lib/src/material/icon.dart index e76477eeb9..c5b62cbaa8 100644 --- a/packages/flutter/lib/src/material/icon.dart +++ b/packages/flutter/lib/src/material/icon.dart @@ -76,7 +76,7 @@ class Icon extends StatelessWidget { if (icon == null) return new SizedBox(width: size, height: size); - final double iconOpacity = IconTheme.of(context)?.clampedOpacity ?? 1.0; + final double iconOpacity = IconTheme.of(context)?.opacity ?? 1.0; Color iconColor = color ?? _getDefaultColor(context); if (iconOpacity != 1.0) iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); diff --git a/packages/flutter/lib/src/material/icon_theme_data.dart b/packages/flutter/lib/src/material/icon_theme_data.dart index de1ee0856b..3a5b34414f 100644 --- a/packages/flutter/lib/src/material/icon_theme_data.dart +++ b/packages/flutter/lib/src/material/icon_theme_data.dart @@ -12,23 +12,22 @@ import 'dart:ui' show Color, hashValues; class IconThemeData { /// Creates an icon theme data. /// - /// The given opacity applies to both explicit and default icon colors. - const IconThemeData({ this.color, this.opacity }); + /// The opacity applies to both explicit and default icon colors. The value + /// is clamped between 0.0 and 1.0. + const IconThemeData({ this.color, double opacity: 1.0 }) : _opacity = opacity; /// The default color for icons. final Color color; /// An opacity to apply to both explicit and default icon colors. - final double opacity; - - /// Normalizes the given opacity to be between 0.0 and 1.0 (inclusive). - double get clampedOpacity => (opacity ?? 1.0).clamp(0.0, 1.0); + double get opacity => (_opacity ?? 1.0).clamp(0.0, 1.0); + final double _opacity; /// Linearly interpolate between two icon theme data objects. static IconThemeData lerp(IconThemeData begin, IconThemeData end, double t) { return new IconThemeData( color: Color.lerp(begin.color, end.color, t), - opacity: ui.lerpDouble(begin.clampedOpacity, end.clampedOpacity, t) + opacity: ui.lerpDouble(begin.opacity, end.opacity, t) ); } diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 7556fda46c..246558e815 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -96,6 +96,7 @@ class _PopupMenuItemState> extends State { duration: kThemeChangeDuration, child: new Baseline( baseline: config.height - _kBaselineOffsetFromBottom, + baselineType: TextBaseline.alphabetic, child: buildChild() ) );