Skip to content

Commit f32130a

Browse files
Update FractionalOffsetUtil.dart
1 parent 9c7787c commit f32130a

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

projects/util/FractionalOffsetUtil.dart

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import 'package:flutter/material.dart';
22

3-
/// LinearGradient 线性渐变封装
4-
/// 一共有12种组合方式
5-
/// 用法:在有gradient属性的地方使用:例如:
6-
/// 首先要导包,import 'FractionalOffsetUtil.dart';
7-
/// 然后再去使用
3+
/// LinearGradient 线性渐变封装
4+
/// 一共有12种组合方式
5+
/// 用法:在有gradient属性的地方使用:例如:
6+
/// 首先要导包,import 'FractionalOffsetUtil.dart';
7+
/// 然后再去使用
88
/// gradient: setFractionalOffsets(Type.leftBottomToRightTop, null),
9-
/// 再例如:
9+
/// 再例如:
1010
/// gradient: setFractionalOffsets(Type.leftToRight, Direction.firstDirection),
1111
1212
LinearGradient setFractionalOffsets(
@@ -40,12 +40,7 @@ LinearGradient setFractionalOffsets(
4040
LinearGradient DirectionStyle(
4141
double startX, double startY, double endX, double endY) {
4242
var linearGradient = new LinearGradient(
43-
//线性渐变
44-
begin: FractionalOffset(startX, startY),
45-
end: FractionalOffset(endX, endY),
46-
colors: <Color>[Colors.deepOrange, Colors.deepPurple],
47-
);
48-
return linearGradient;
43+
return DirectionStyle2(null, startX, startY, endX, endY, -1, -1, -1, -1);
4944
}
5045

5146
LinearGradient DirectionStyle2(
@@ -64,30 +59,30 @@ LinearGradient DirectionStyle2(
6459
direction == Direction.firstDirection ? endY = endY : endY2;
6560

6661
var linearGradient = new LinearGradient(
67-
//线性渐变
62+
//线性渐变
6863
begin: FractionalOffset(startX, startY),
6964
end: FractionalOffset(endX, endY),
7065
colors: <Color>[Colors.deepOrange, Colors.deepPurple],
7166
);
7267
return linearGradient;
7368
}
7469

75-
// 因为从上到下,或者从左到右 都有两种可能。
76-
// 从上到下 包括: 左上 -> 左下 右上 -> 右下
77-
// 从左到右 包括: 左上 -> 右上 左下 -> 右下
70+
// 因为从上到下,或者从左到右 都有两种可能。
71+
// 从上到下 包括: 左上 -> 左下 右上 -> 右下
72+
// 从左到右 包括: 左上 -> 右上 左下 -> 右下
7873
enum Direction {
79-
firstDirection,//如果是从上到下: 左上 -> 左下,如果是从左到右:左上 -> 右上
80-
lastPointDirection,// 如果是从上到下: 右上 -> 右下,如果是从左到右:左下 -> 右下
74+
firstDirection,//如果是从上到下: 左上 -> 左下,如果是从左到右:左上 -> 右上
75+
lastPointDirection,// 如果是从上到下: 右上 -> 右下,如果是从左到右:左下 -> 右下
8176
}
8277

8378
enum Type {
84-
//8个方向
85-
leftToRight, //→
86-
rightToLeft, //←
87-
topToBottom, //↓
88-
bottomToTop, //↑
89-
leftTopToRightBottom, //↘
90-
rightBottomToLeftTop, //↖
91-
rightTopToLeftBottom, //↙
92-
leftBottomToRightTop, //↗
79+
//8个方向
80+
leftToRight, //→
81+
rightToLeft, //←
82+
topToBottom, //↓
83+
bottomToTop, //↑
84+
leftTopToRightBottom, //↘
85+
rightBottomToLeftTop, //↖
86+
rightTopToLeftBottom, //↙
87+
leftBottomToRightTop, //↗
9388
}

0 commit comments

Comments
 (0)