Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8c302ef
upgrade to null safety
lslv1243 Jan 2, 2021
467de07
updated dependencies
lslv1243 May 4, 2021
eb3efbd
remove unnecessary late
lslv1243 May 4, 2021
87f654c
using Pigment lib instead of reimplementing colorFromString
lslv1243 May 4, 2021
56d7d94
Update issue templates
calvintam236 Jun 24, 2021
f61116c
Update pubspec for this fork
calvintam236 Jun 24, 2021
f431be7
Update underlying color with setting alpha and opacity.
TNorbury Jun 24, 2021
2f13899
restructure as a library
TNorbury Jun 24, 2021
1997311
format code for pub points
TNorbury Jun 24, 2021
797606a
Fixes issues #2 and #10 in FooStudio/tinycolor
dsyrstad Jun 24, 2021
ee3ab47
Merge pull request #5 from dsyrstad/master
calvintam236 Jun 25, 2021
acf1be2
Merge remote-tracking branch 'upstream/master' into fix_set_alpha_opa…
TNorbury Jun 25, 2021
68d18fd
spelling
TNorbury Jun 25, 2021
1fc89ce
Create SECURITY.md
calvintam236 Jun 26, 2021
7ab3574
Update issue templates
calvintam236 Jun 26, 2021
ee0125f
Merge pull request #9 from TinyCommunity/hotfix/issues-template
calvintam236 Jun 26, 2021
2d25c26
Merge pull request #10 from TinyCommunity/hotfix/security-policy
calvintam236 Jun 26, 2021
3cf7078
Update changelog template
calvintam236 Jun 29, 2021
89c7b9d
Merge pull request #12 from TinyCommunity/hotfix/changelog
calvintam236 Jun 29, 2021
e33128c
Merge pull request #4 from TNorbury/fix_set_alpha_opacity
calvintam236 Jul 4, 2021
eebc84c
Replace .gitignore from flutter/packages
calvintam236 Jul 4, 2021
a331464
Reimport .gitignore from dart template
calvintam236 Jul 4, 2021
d9737dc
Remove pubspec.lock
calvintam236 Jul 4, 2021
1274905
Merge pull request #14 from TinyCommunity/patch-gitignore
calvintam236 Jul 4, 2021
4b92abe
Add .equals() (#16)
calvintam236 Jul 7, 2021
c7b9db7
Fix #19
calvintam236 Jul 8, 2021
627818f
Merge pull request #20 from TinyCommunity/bugfix/hashcode
calvintam236 Jul 8, 2021
983245c
Update with template gitignore
calvintam236 Jul 8, 2021
4806874
Ignore OS related files
calvintam236 Jul 8, 2021
825a1b4
Ignore IDE related files
calvintam236 Jul 8, 2021
a6e7c4a
Add .toHex8() (#17)
calvintam236 Jul 8, 2021
c2c29d5
Merge pull request #21 from TinyCommunity/hotfix/gitignore
calvintam236 Jul 9, 2021
5a58244
Add autogenerated files in .idea/ folder (#22)
WieFel Jul 11, 2021
e52805a
Add component ProjectRootManager line in misc.xml (#23)
WieFel Jul 11, 2021
d3710c1
rename method copy -> clone
lslv1243 Jul 13, 2021
5b4b323
Merge https://github.com/TinyCommunity/tinycolor2
lslv1243 Jul 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
226 changes: 0 additions & 226 deletions lib/color_from_string.dart

This file was deleted.

19 changes: 12 additions & 7 deletions lib/tinycolor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'dart:math' as Math;
import 'dart:ui';

import 'package:flutter/painting.dart';
import 'package:pigment/pigment.dart';

import 'color_from_string.dart';
import 'conversion.dart';
import 'hsl_color.dart';
import 'util.dart';
Expand All @@ -13,12 +13,11 @@ export 'color_extension.dart';

class TinyColor {
final Color originalColor;
late Color _color;
Color _color;

TinyColor(Color color) : this.originalColor = color {
this._color =
Color.fromARGB(color.alpha, color.red, color.green, color.blue);
}
TinyColor(Color color)
: this.originalColor = color,
_color = color.copy();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually thinking just

TinyColor(Color color)
      : this.originalColor = color,
      _color = Color.fromARGB(alpha, red, green, blue);

or is that bad practice somehow? :) the extension seems overkill, just for the internals of a constructor. Or do you believe it is generally useful? Personally I haven't had the need yet.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would actually be (reference color):

TinyColor(Color color)
      : this.originalColor = color,
      _color = Color.fromARGB(color.alpha, color.red, color.green, color.blue);

I don't think it is overkill, since the extension is private.
I am used to creating extensions for these cases to simplify the constructor and improve formatting, but it is just a matter of taste.
Both ways will produce the same end result, as of before, it was allowing the variable to not be initialized if somebody was to change the constructor and probably adding a tiny runtime penalty.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I forgot the color ref.
sorry, I did not realize it was a private extension. thanks for explaining


factory TinyColor.fromRGB(
{required int r, required int g, required int b, int a = 100}) {
Expand All @@ -34,7 +33,7 @@ class TinyColor {
}

factory TinyColor.fromString(String string) {
return TinyColor(colorFromString(string));
return TinyColor(Pigment.fromString(string));
}

bool isDark() {
Expand Down Expand Up @@ -159,3 +158,9 @@ class TinyColor {
return _color;
}
}

extension on Color {
Color copy() {
return Color.fromARGB(alpha, red, green, blue);
}
}
Loading