from_css_color
2.0.0Creates Color instance from CSS color string according to https://drafts.csswg.org/css-color-3
Showing cached metadata. Upstream refresh is currently unavailable.
Readme
From CSS Color
A package that creates Flutter Color instances from CSS color strings according to CSS Color Module Level 3. Hex, RGB(A), HSL(A) and X11 keywords are supported.
Backwards conversion from Color to CSS color string is also available with toCssColor() extention method.
Usage
To use this plugin, add from_css_color as a dependency in your pubspec.yaml file.
Example
Import the library.
import 'package:from_css_color/from_css_color.dart';
Use it anywhere you want to create a Color from CSS color definition format:
Container(
color: fromCssColor('#ff00aa'),
// ...
)
Container(
color: fromCssColor('rgb(100, 5, 32)'),
// ...
)
Convert Color back to CSS string:
final color = const Color(0xFFFBAFBA);
color.toCssString(); // '#fbafba'
Check CSS color string correctness:
isCssColor('#ff00aa'); // true
Visit examples for more details.
Changelog
2.0.0
- Migrate to null-safety.
- Remove fromCSSColor()/isCSSColor(), which was deprecated since 1.2.0 in favor of fromCssColor()/isCssColor() to meet the effective Dart style guide.
1.2.0
- Add
isCssColor()function to check color string format correctness.
1.1.0
- Add
toCssColor()extension method to convert Color instance to CSS color string.
1.0.0
- Add support for 4 (#rgba) and 8 (#rrggbbaa) digit hex colors.
- Update versioning to stable after 3 months of usage in production (no breaking changes expected).
0.1.1
- Update readme and file formatting.
0.1.0
- Support for 'transparent' color keyword.
- Support for hsl/hsla colors.
0.0.1
- Support for 3 and 6 digit hex colors.
- Support for rgb/rgba colors.
- Support for X11 keywords.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add from_css_colorpubspec.yaml
name: from_css_color
description: Creates Color instance from CSS color string according to https://drafts.csswg.org/css-color-3
version: 2.0.0
homepage: https://github.com/alex-myznikov/from_css_color.git
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutterVersion history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.0.1 | Cached · Upstream SHA-256 matched | Download | c42d75c8…c64f56 |
| 0.1.0 | Cached · Upstream SHA-256 matched | Download | 62c6a364…439af0 |
| 0.1.1 | Cached · Upstream SHA-256 matched | Download | dc52f291…fdc86a |
| 1.0.0 | Cached · Upstream SHA-256 matched | Download | 9ba8cee9…7c94ee |
| 1.1.0 | Cached · Upstream SHA-256 matched | Download | a018fa1a…4d5da5 |
| 1.2.0 | Cached · Upstream SHA-256 matched | Download | b1aa1563…b27870 |
| 2.0.0 | Cached · Upstream SHA-256 matched | Download | 5e4d1795…d20823 |
Dependencies
flutter {
"sdk": "flutter"
}