1
1
import 'package:flutter/material.dart' ;
2
2
3
- /// LinearGradient 线性渐变封装
4
- /// 一共有12种组合方式
5
- /// 用法:在有gradient属性的地方使用:例如:
6
- /// 首先要导包,import 'FractionalOffsetUtil.dart';
7
- /// 然后再去使用
3
+ /// LinearGradient 线性渐变封装
4
+ /// 一共有12种组合方式
5
+ /// 用法:在有gradient属性的地方使用:例如:
6
+ /// 首先要导包,import 'FractionalOffsetUtil.dart';
7
+ /// 然后再去使用
8
8
/// gradient: setFractionalOffsets(Type.leftBottomToRightTop, null),
9
- /// 再例如:
9
+ /// 再例如:
10
10
/// gradient: setFractionalOffsets(Type.leftToRight, Direction.firstDirection),
11
11
12
12
LinearGradient setFractionalOffsets (
@@ -40,12 +40,7 @@ LinearGradient setFractionalOffsets(
40
40
LinearGradient DirectionStyle (
41
41
double startX, double startY, double endX, double endY) {
42
42
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 );
49
44
}
50
45
51
46
LinearGradient DirectionStyle2 (
@@ -64,30 +59,30 @@ LinearGradient DirectionStyle2(
64
59
direction == Direction .firstDirection ? endY = endY : endY2;
65
60
66
61
var linearGradient = new LinearGradient (
67
- //线性渐变
62
+ //线性渐变
68
63
begin: FractionalOffset (startX, startY),
69
64
end: FractionalOffset (endX, endY),
70
65
colors: < Color > [Colors .deepOrange, Colors .deepPurple],
71
66
);
72
67
return linearGradient;
73
68
}
74
69
75
- // 因为从上到下,或者从左到右 都有两种可能。
76
- // 从上到下 包括: 左上 -> 左下 右上 -> 右下
77
- // 从左到右 包括: 左上 -> 右上 左下 -> 右下
70
+ // 因为从上到下,或者从左到右 都有两种可能。
71
+ // 从上到下 包括: 左上 -> 左下 右上 -> 右下
72
+ // 从左到右 包括: 左上 -> 右上 左下 -> 右下
78
73
enum Direction {
79
- firstDirection,//如果是从上到下: 左上 -> 左下,如果是从左到右:左上 -> 右上
80
- lastPointDirection,// 如果是从上到下: 右上 -> 右下,如果是从左到右:左下 -> 右下
74
+ firstDirection,//如果是从上到下: 左上 -> 左下,如果是从左到右:左上 -> 右上
75
+ lastPointDirection,// 如果是从上到下: 右上 -> 右下,如果是从左到右:左下 -> 右下
81
76
}
82
77
83
78
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, //↗
93
88
}
0 commit comments