Random color generator for Flutter

Overview

Random color generator

pub package CodeFactor

Pub link: https://pub.dartlang.org/packages/random_color

This library will generate random colors that are visually pleasing and can be customized by passing custom hue, saturation and brightness range. This allows it to generate just specific color with slight differences.

Blue colors:

Red colors:

Green:

Low saturation:

High saturation:

Light colors:

Dark colors:

Usage

Getting random color:

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
Comments
  • Support null safety

    Support null safety

    This is a request to add support for null safety to package:random_color. We depend on your awesome package, so would be great to have null safety enabled.

    The Dart/Flutter team already encourages publishing the migrated packages: See this blog post.

    See the migration guide for details about enabling null safety.

    opened by IchordeDionysos 4
  • Error: Cannot run with sound null safety, because the following dependencies don't support null safety:

    Error: Cannot run with sound null safety, because the following dependencies don't support null safety:

    Hello i am trying to user this package but when i install dependicy then run the app it will show me this error as red line : (

    Plz update

    Error: Cannot run with sound null safety, because the following dependencies don't support null safety:

    opened by nawzhin95 2
  • Null safety and pedantic analysis

    Null safety and pedantic analysis

    Hi!

    Thought I would move this over to null-safety. I had to remove the example lib and recreate it using flutter create again because there was some hefty manual changes that it was asking me to do otherwise. I also added analysis options so that things could be more consistent.

    Let me know if this is unwelcome or if you want any changes. I tested example on android, iOS and web and all worked ok.

    Thanks!

    opened by Nolence 2
  • How can I make the color static?

    How can I make the color static?

    I've just implemented this package on my app, but It keep changing its color. Please see this recording.

    ezgif-2-f063ccb33a08

    Is there any way to prevent this? *Please note that the Title field has nothing to do with the participant chips.

    opened by pratamatama 2
  • pub get failed

    pub get failed

    [theapp] flutter packages get Running "flutter packages get" in theapp...
    Because every version of flutter_test from sdk depends on test 1.3.0 and every version of random_color depends on test ^1.3.4, flutter_test from sdk is incompatible with random_color. So, because theapp depends on both random_color ^1.0.0 and flutter_test any from sdk, version solving failed.

    pub get failed (1) exit code 1

    opened by codeXLinkX 2
  • Getting random color from range

    Getting random color from range

    How would one generate random color from range using your library? The input is Color from and Color to.

    I think a method like this would be very useful. Possibly, by using regular Color from dart:ui instead of some custom classes.

    opened by itsJoKr 1
  • const, ==, hashCode, multiple

    const, ==, hashCode, multiple

    Made ColorSaturation const Made ColorBrightness const Made Range const (breaking change: addition doesn't mutate the range object anymore but returns a new Range) Added == & hashcode to ColorSaturation, ColorBrightness & Range Added multiple to ColorBrightness & ColorBrightnes.

    opened by modulovalue 1
  • [Feature request] Random color palette

    [Feature request] Random color palette

    Hi πŸ‘‹ it would be nice to have a way to generate a random color palette like randomColors except not by passing a single hue as argument, but passing hue min and hue max.

    A good example here

    Best regards.

    opened by RichardFevrier 0
Owner
Luka Knezic
Flutter developer
Luka Knezic
πŸš€The Flutter dart code generator from zeplin. ex) Container, Text, Color, TextStyle, ... - Save your time.

Flutter Gen Zeplin Extension ?? The Flutter dart code generator from zeplin. ex) Container, Text, Color, TextStyle, ... - Save your time. ⬇ 1.1k Getti

NAVER 49 Oct 12, 2022
Flutter Cool Random User Generate πŸ”₯πŸ”₯

Flutter Cool Random User Generate ????

Hmida 8 Sep 10, 2022
An alternative random library for Dart.

Randt Randt library for Dart... Description Use Randt to get a random integer from a list, generate random integer in a specific range and generate ra

Bangladesh Coding Soldierz 3 Nov 21, 2021
apps random

flutter_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

Tajul Aulia Muda 1 Oct 21, 2021
Generate random data(string, integer, IPs etc...) using Dart.

Generate random data using Features API provides generation of: Integers in any range of numbers Strings with various characters and length Colors rep

Dinko Pehar 14 Apr 17, 2022
Simple library for generating random ascii strings

random_string Simple library for generating random ascii strings. Design goals and limitations While this package provides randomBetween for convenien

Damon Douglas 24 Nov 19, 2022
Dart package for random strings and numbers, with weights

randomness Dart package for random strings and numbers, with weights Random strings, numbers. RNG with weights. Cryptographically secure options. Gett

null 2 Aug 6, 2022
Minimal Dart wrapper to interact with Some Random Api. Easy to use, simplified and lightweight.

SRA - Some Random Api Minimal Dart wrapper to interact with Some Random Api. Easy to use, simplified and lightweight. Getting started Add the package

Yakiyo 3 Jan 4, 2023
Flutter plugin to help experiment with different Color Schemes without pain.

Random Color Scheme Making a coherent Material Design theme is hard. This is a Flutter plugin that generates a random color pallet based on Material D

Bernardo Ferrari 77 Dec 6, 2022
Material color utilities

Material color utilities Algorithms and utilities that power the Material Design 3 (M3) color system, including choosing theme colors from images and

null 878 Jan 8, 2023
Starter project and code generator for Flutter/Redux

Flutter Redux Starter/Code Generator Videos Short video ~ 1 minute Long video ~ 10 minutes We're using this approach to develop the Flutter app for In

Hillel Coren 278 Dec 12, 2022
Environment specific config generator for Dart and Flutter applications during CI/CD builds

Environment Config Generator Environment specific config generator. Allows to specify env configuration during CI/CD build. Primarily created to simpl

Denis Beketsky 86 Dec 2, 2022
The Flutter code generator for your assets, fonts, colors, … β€” Get rid of all String-based APIs.

The Flutter code generator for your assets, fonts, colors, … β€” Get rid of all String-based APIs. Inspired by SwiftGen. Motivation Using asset path str

FlutterGen 1.1k Jan 6, 2023
A Flutter curl-command generator for Dio

curl_logger_dio_interceptor A Flutter curl-command generator for Dio. Easily test your Flutter-made requests in your favorite terminal or even in Post

null 7 Nov 17, 2022
OpenAPI generator for Dart & Flutter

Fantom Fantom is a cli tool for generating API layer based on OpenAPI Spec. Usage Install fantom $ dart pub global activate fantom Generate API client

6thSolution 13 Oct 18, 2022
OpenAPI generator for Dart & Flutter

Fantom Fantom is a cli tool for generating API layer based on OpenAPI Spec. Usage Install fantom $ dart pub global activate fantom Generate API client

REKAB 13 Oct 18, 2022
Flutter Word generator

wordpair_generator A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Aristide Sabi 0 Dec 3, 2021
A Flutter Word generator App to improve English vocabulary

Word generator App to improve English vocabulary: Add English words you don't know and their translation, then you need to answer what is the translat

Gustavo Bonassa 1 Dec 12, 2021
Swagger/OpenAPI code generator based on Chopper and JsonAnnotation for Flutter

Code partially generated with chopper ?? Build dart types from Swagger/OpenAPI schemas SwaggerDartCodeGenerator is a code generator that looks for *.s

null 187 Jan 5, 2023