File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
projects/flutter-demo/lib Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -125,4 +125,40 @@ void test() {
125
125
color6.withBlue (100 );
126
126
// 替换掉原来颜色中的 opacity 值
127
127
color6.withOpacity (0.8 );
128
+
129
+
130
+ // 测试 fromRGBA 的用法
131
+ Color rgbaColor = fromRGBA (255 , 181 , 181 , 255 );
132
+ int red7 = rgbaColor.red;
133
+ int green7 = rgbaColor.green;
134
+ int blue7 = rgbaColor.blue;
135
+ int alpha7 = rgbaColor.alpha;
136
+ print ("rgbaColor: " +
137
+ " red: " +
138
+ red7.toString () +
139
+ " green: " +
140
+ green7.toString () +
141
+ " blue: " +
142
+ blue7.toString () +
143
+ " alpha: " +
144
+ alpha7.toString ()); // red: 255 green: 181 blue: 181 alpha: 255
145
+ }
146
+
147
+ // 设置把原有的ARGB方式转换成 RGBA,更符合某一些人的使用习惯
148
+ Color fromRGBA (int red, int green, int blue, int alpha){
149
+ // 方式2: 参数4为:不透明度(0是完全透明,255是完全不透明)
150
+ Color color2 = Color .fromARGB (255 , 255 , 181 , 181 );
151
+ int alpha2 = color2.alpha;
152
+ int red2 = color2.red;
153
+ int green2 = color2.green;
154
+ int blue2 = color2.blue;
155
+ print ("color2: " +
156
+ " alpha: " +
157
+ alpha1.toString () +
158
+ " red: " +
159
+ red2.toString () +
160
+ " green: " +
161
+ green2.toString () +
162
+ " blue: " +
163
+ blue2.toString ()); // alpha: 255 red: 255 green: 181 blue: 181
128
164
}
You can’t perform that action at this time.
0 commit comments