in

Random color generator for Flutter

Random color generator

Color plays an important role in how we perceive, its influence is so deeply ingrained in everyday life, that often we barely notice it.
Therefore, this library will generate random colors that are great visual impact and pleasing and can be customized by moving custom hue, saturation, and brightness range. This is so great to allow it to generate just specific colors with slight differences.

BLUE COLORS:
BLUE random color
RED COLORS:
Red
GREEN:
Green
LOW SATURATION:
Low-saturation2
HIGH SATURATION:
High-saturation
LIGHT COLORS:
Light-colors
DARK COLORS:
Dark-colors

Usage

Getting random color:

The random color function can be called with parameters colorHue, colorSaturation and colorBrightness
allowing for customization of colors the generator will pass.

import 'package:random_color/random_color.dart';

RandomColor _randomColor = RandomColor();

Color _color = _randomColor.randomColor();

Getting color name:

You can get color name from hex string (without # and alpha hex values) or from Color object

  Color _color = Color('FF0000'.toStringRadix(16));
  MyColor _myColor = getColorNameFromColor(_color);

  // Prints: 'Red'
  print(_myColor.getName);

Get just red colors:

Random color can generate just specific color type, as long hue, saturation and brightness are not
too limiting this will still give rich result

import 'package:random_color/random_color.dart';

RandomColor _randomColor = RandomColor();

Color _color = _randomColor.randomColor(colorHue: ColorHue.red);

Get just red and blue colors:

You can combine multiple hue ranges to choose from

import 'package:random_color/random_color.dart';

RandomColor _randomColor = RandomColor();

Color _color = _randomColor.randomColor(
  colorHue: ColorHue.multiple([ColorHue.red, ColorHue.blue])
);

Get highly saturated colors:
import 'package:random_color/random_color.dart';

RandomColor _randomColor = RandomColor();

Color _color = _randomColor.randomColor(
  colorSaturation: ColorSaturation.highSaturation
);

Get light colors:
import 'package:random_color/random_color.dart';

RandomColor _randomColor = RandomColor();

Color _color = _randomColor.randomColor(
  colorBrightness: ColorBrightness.light
);

Tests

If you want to run the tests for this project under Flutter Dart

flutter pub pub run test

GitHub

https://github.com/knezzz/RandomColor

Written by James

A flexible and lightweight flutter canvas graphic animation library

A HSV color picker inspired by chrome devtools and a material color picker