Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
代码之道
Flutter
提交
ebb48e16
F
Flutter
项目概览
代码之道
/
Flutter
9 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flutter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
ebb48e16
编写于
10月 28, 2021
作者:
E
Everskies
提交者:
GitHub
10月 27, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add missing transform == check for gradients (#91898)
上级
bb6e3aff
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
92 addition
and
7 deletion
+92
-7
packages/flutter/lib/src/painting/gradient.dart
packages/flutter/lib/src/painting/gradient.dart
+57
-6
packages/flutter/test/painting/gradient_test.dart
packages/flutter/test/painting/gradient_test.dart
+35
-1
未找到文件。
packages/flutter/lib/src/painting/gradient.dart
浏览文件 @
ebb48e16
...
...
@@ -118,6 +118,24 @@ class GradientRotation extends GradientTransform {
..
translate
(
originX
,
originY
)
..
rotateZ
(
radians
);
}
@override
bool
operator
==(
Object
other
)
{
if
(
identical
(
this
,
other
))
return
true
;
if
(
other
.
runtimeType
!=
runtimeType
)
return
false
;
return
other
is
GradientRotation
&&
other
.
radians
==
radians
;
}
@override
int
get
hashCode
=>
radians
.
hashCode
;
@override
String
toString
()
{
return
'
${objectRuntimeType(this, 'GradientRotation')}
(radians:
${debugFormatDouble(radians)}
)'
;
}
}
/// A 2D gradient.
...
...
@@ -495,16 +513,26 @@ class LinearGradient extends Gradient {
&&
other
.
begin
==
begin
&&
other
.
end
==
end
&&
other
.
tileMode
==
tileMode
&&
other
.
transform
==
transform
&&
listEquals
<
Color
>(
other
.
colors
,
colors
)
&&
listEquals
<
double
>(
other
.
stops
,
stops
);
}
@override
int
get
hashCode
=>
hashValues
(
begin
,
end
,
tileMode
,
hashList
(
colors
),
hashList
(
stops
));
int
get
hashCode
=>
hashValues
(
begin
,
end
,
tileMode
,
transform
,
hashList
(
colors
),
hashList
(
stops
));
@override
String
toString
()
{
return
'
${objectRuntimeType(this, 'LinearGradient')}
(
$begin
,
$end
,
$colors
,
$stops
,
$tileMode
)'
;
final
List
<
String
>
description
=
<
String
>[
'begin:
$begin
'
,
'end:
$end
'
,
'colors:
$colors
'
,
if
(
stops
!=
null
)
'stops:
$stops
'
,
'tileMode:
$tileMode
'
,
if
(
transform
!=
null
)
'transform:
$transform
'
,
];
return
'
${objectRuntimeType(this, 'LinearGradient')}
(
${description.join(', ')}
)'
;
}
}
...
...
@@ -757,6 +785,7 @@ class RadialGradient extends Gradient {
&&
other
.
center
==
center
&&
other
.
radius
==
radius
&&
other
.
tileMode
==
tileMode
&&
other
.
transform
==
transform
&&
listEquals
<
Color
>(
other
.
colors
,
colors
)
&&
listEquals
<
double
>(
other
.
stops
,
stops
)
&&
other
.
focal
==
focal
...
...
@@ -764,11 +793,22 @@ class RadialGradient extends Gradient {
}
@override
int
get
hashCode
=>
hashValues
(
center
,
radius
,
tileMode
,
hashList
(
colors
),
hashList
(
stops
),
focal
,
focalRadius
);
int
get
hashCode
=>
hashValues
(
center
,
radius
,
tileMode
,
transform
,
hashList
(
colors
),
hashList
(
stops
),
focal
,
focalRadius
);
@override
String
toString
()
{
return
'
${objectRuntimeType(this, 'RadialGradient')}
(
$center
,
$radius
,
$colors
,
$stops
,
$tileMode
,
$focal
,
$focalRadius
)'
;
final
List
<
String
>
description
=
<
String
>[
'center:
$center
'
,
'radius:
${debugFormatDouble(radius)}
'
,
'colors:
$colors
'
,
if
(
stops
!=
null
)
'stops:
$stops
'
,
'tileMode:
$tileMode
'
,
if
(
focal
!=
null
)
'focal:
$focal
'
,
'focalRadius:
${debugFormatDouble(focalRadius)}
'
,
if
(
transform
!=
null
)
'transform:
$transform
'
,
];
return
'
${objectRuntimeType(this, 'RadialGradient')}
(
${description.join(', ')}
)'
;
}
}
...
...
@@ -1005,15 +1045,26 @@ class SweepGradient extends Gradient {
&&
other
.
startAngle
==
startAngle
&&
other
.
endAngle
==
endAngle
&&
other
.
tileMode
==
tileMode
&&
other
.
transform
==
transform
&&
listEquals
<
Color
>(
other
.
colors
,
colors
)
&&
listEquals
<
double
>(
other
.
stops
,
stops
);
}
@override
int
get
hashCode
=>
hashValues
(
center
,
startAngle
,
endAngle
,
tileMode
,
hashList
(
colors
),
hashList
(
stops
));
int
get
hashCode
=>
hashValues
(
center
,
startAngle
,
endAngle
,
tileMode
,
transform
,
hashList
(
colors
),
hashList
(
stops
));
@override
String
toString
()
{
return
'
${objectRuntimeType(this, 'SweepGradient')}
(
$center
,
$startAngle
,
$endAngle
,
$colors
,
$stops
,
$tileMode
)'
;
final
List
<
String
>
description
=
<
String
>[
'center:
$center
'
,
'startAngle:
${debugFormatDouble(startAngle)}
'
,
'endAngle:
${debugFormatDouble(endAngle)}
'
,
'colors:
$colors
'
,
if
(
stops
!=
null
)
'stops:
$stops
'
,
'tileMode:
$tileMode
'
,
if
(
transform
!=
null
)
'transform:
$transform
'
,
];
return
'
${objectRuntimeType(this, 'SweepGradient')}
(
${description.join(', ')}
)'
;
}
}
packages/flutter/test/painting/gradient_test.dart
浏览文件 @
ebb48e16
...
...
@@ -184,17 +184,51 @@ void main() {
const
LinearGradient
(
begin:
Alignment
.
topLeft
,
end:
Alignment
.
bottomLeft
,
transform:
GradientRotation
(
1.6
),
colors:
<
Color
>[
Color
(
0x33333333
),
Color
(
0x66666666
),
],
).
toString
(),
equals
(
'LinearGradient(
Alignment.topLeft, Alignment.bottomLeft, [Color(0x33333333), Color(0x66666666)], null, TileMode.clamp
)'
,
'LinearGradient(
begin: Alignment.topLeft, end: Alignment.bottomLeft, colors: [Color(0x33333333), Color(0x66666666)], tileMode: TileMode.clamp, transform: GradientRotation(radians: 1.6)
)'
,
),
);
});
test
(
'LinearGradient with different transforms'
,
()
{
const
LinearGradient
testGradient1
=
LinearGradient
(
transform:
GradientRotation
(
math
.
pi
/
4
),
colors:
<
Color
>[
Color
(
0x33333333
),
Color
(
0x66666666
),
],
);
const
LinearGradient
testGradient1Copy
=
LinearGradient
(
transform:
GradientRotation
(
math
.
pi
/
4
),
colors:
<
Color
>[
Color
(
0x33333333
),
Color
(
0x66666666
),
],
);
const
LinearGradient
testGradient2
=
LinearGradient
(
transform:
GradientRotation
(
math
.
pi
/
2
),
colors:
<
Color
>[
Color
(
0x33333333
),
Color
(
0x66666666
),
],
);
expect
(
testGradient1
,
equals
(
testGradient1Copy
),
);
expect
(
testGradient1
,
isNot
(
equals
(
testGradient2
)),
);
});
test
(
'LinearGradient with AlignmentDirectional'
,
()
{
expect
(
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录