Skip to content

Commit 671b9cf

Browse files
authored
Merge pull request #33 from warioddly/31-refactor-colorutil
31 refactor colorutil
2 parents 8f3dbaf + 87945c8 commit 671b9cf

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/src/utils/color_extension.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import 'dart:ui' show Color;
2+
3+
extension ColorExtension on Color {
4+
5+
String get toRGBA {
6+
return 'rgba(${(red * 255).toInt()}, ${(green * 255).toInt()}, ${(blue * 255).toInt()}, ${opacity})';
7+
}
8+
9+
}

lib/src/utils/color_util.dart

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/src/utils/gradient/graphify_gradient.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dart:ui';
2-
import 'package:graphify/src/utils/color_util.dart';
2+
import 'package:graphify/src/utils/color_extension.dart';
33

44
abstract class GraphifyGradient {
55
const GraphifyGradient({
@@ -45,7 +45,7 @@ class GraphifyGradientColorStop {
4545
Map<String, dynamic> toJson() {
4646
return <String, dynamic>{
4747
'offset': offset,
48-
'color': ColorUtils.colorToRgba(color),
48+
'color': color.toRGBA,
4949
};
5050
}
5151
}

0 commit comments

Comments
 (0)