Skip to content

A Flutter package that creates Color instance from CSS color string according to https://drafts.csswg.org/css-color-3

License

Notifications You must be signed in to change notification settings

Mr-Apisit/dart_from_css_color

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A Flutter package that creates Color instance from CSS color string according to https://drafts.csswg.org/css-color-3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 100.0%