Unverified Commit a2814a61 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Added identical(a,b) short circuit ... finale (#121759)

parent c9eda9b3
...@@ -835,8 +835,8 @@ class _CupertinoEdgeShadowDecoration extends Decoration { ...@@ -835,8 +835,8 @@ class _CupertinoEdgeShadowDecoration extends Decoration {
_CupertinoEdgeShadowDecoration? b, _CupertinoEdgeShadowDecoration? b,
double t, double t,
) { ) {
if (a == null && b == null) { if (identical(a, b)) {
return null; return a;
} }
if (a == null) { if (a == null) {
return b!._colors == null ? b : _CupertinoEdgeShadowDecoration._(b._colors!.map<Color>((Color color) => Color.lerp(null, color, t)!).toList()); return b!._colors == null ? b : _CupertinoEdgeShadowDecoration._(b._colors!.map<Color>((Color color) => Color.lerp(null, color, t)!).toList());
......
...@@ -167,6 +167,9 @@ class IconThemeData with Diagnosticable { ...@@ -167,6 +167,9 @@ class IconThemeData with Diagnosticable {
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static IconThemeData lerp(IconThemeData? a, IconThemeData? b, double t) { static IconThemeData lerp(IconThemeData? a, IconThemeData? b, double t) {
if (identical(a, b) && a != null) {
return a;
}
return IconThemeData( return IconThemeData(
size: ui.lerpDouble(a?.size, b?.size, t), size: ui.lerpDouble(a?.size, b?.size, t),
fill: ui.lerpDouble(a?.fill, b?.fill, t), fill: ui.lerpDouble(a?.fill, b?.fill, t),
......
...@@ -57,6 +57,12 @@ void main() { ...@@ -57,6 +57,12 @@ void main() {
expect(lerped.shadows, const <Shadow>[Shadow(color: Color(0xFFFFFFFF), blurRadius: 0.25, offset: Offset(0.25, 0.25))]); expect(lerped.shadows, const <Shadow>[Shadow(color: Color(0xFFFFFFFF), blurRadius: 0.25, offset: Offset(0.25, 0.25))]);
}); });
test('IconThemeData lerp special cases', () {
expect(IconThemeData.lerp(null, null, 0), const IconThemeData());
const IconThemeData data = IconThemeData();
expect(identical(IconThemeData.lerp(data, data, 0.5), data), true);
});
test('with second null', () { test('with second null', () {
final IconThemeData lerped = IconThemeData.lerp(data, null, 0.25); final IconThemeData lerped = IconThemeData.lerp(data, null, 0.25);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment