Flutter library that provides useful functions for working with colors

Overview

Colors Stuff

A library that provides useful functions for working with colors. This is a flutter port of the native Android library colors-ktx library, also made by me.

Features

  • Helpers to tell if a color is dark or light.
  • Helpers to lighten or darken colors.
  • Helpers to manipulate alpha channel of colors.
  • Helpers to generate random dark or light colors.
  • ColorSet - A set of background, foreground and muted foreground colors which you can use in various UI elements of your app.

Usage

Add the library to your pubspec.yaml file:

dependencies:
    colors_stuff: <latest_version>

Import the library.

import 'package:colors_stuff/colors_stuff.dart';

Have fun!

var color = randomColor(); // Generates a random color
var isDark = isColorDark(color); // Returns true if the color is dark

var lightColor = lightenColor(color, 0.2); // Lightens the color by 50%
var darkColor = darkenColor(color); // Darkens the color (by 10% default)

var reducedAlphaColor = reduceAlpha(color); // Reduces the alpha (by 10% default)
var increasedAlphaColor = increaseAlpha(color, 0.5); // Increases the alpha by 50%

But there's more! The ColorSet class generates foreground and muted foreground colors for you based on the background color that you pass to it. You can also have the ColorSet class generate a random background color for you, which will then be used to generate corresponding foreground and muted foreground colors. You can use these colors in various UI elements of your app, without having to worry about whether the foreground color will be legible on the background or not.

var set = ColorSet.ofSomeRandomColor(); // Generates a set with random background color.
...
// Now some where in your UI logic, you have a card on which you have some text.
// You can use the set colors easily to style the card.
Card(
    color: set.backgroundColor,
    child: Padding(
        padding: EdgeInsets.all(24),
        child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
            Text(
                "Title",
                style: TextStyle(
                    color: set.foregroundColor),
            ),
            SizedBox(height: 16),
            Text(
                "Some descriptive text",
                style: TextStyle(
                color: set.mutedForegroundColor),
            ),
        ],
        ),
    ),
),
You might also like...

An app made in Flutter to help people choose the colors they will use in their projects!

An app made in Flutter to help people choose the colors they will use in their projects!

Color Picker An app made in Flutter to help people choose the colors they will use in their projects! Features Pick a color from a picker wheel, palet

Nov 27, 2022

Find underused colors, overused magical numbers and the largest classes in any Flutter project.

Find underused colors, overused magical numbers and the largest classes in any Flutter project.

Flutter Resource Ranker It is easy to overuse colors, write magical numbers or long classes. This project has a script to help you detect these. This

Jul 12, 2021

Material color picker, you can customize colors. Selection in two step, first main color and after shades.

Material color picker, you can customize colors. Selection in two step, first main color and after shades.

Flutter Material Color Picker Material Color picker is a Flutter widget, that can be customizable. By default, it's Material Colors, but you can defin

Nov 25, 2022

Selectable Circle where colors can be customized and a child widget can be defined

Selectable Circle where colors can be customized and a child widget can be defined

selectable_circle A Flutter package for an Circle that can be Selected with animation. How to use SelectableCircle( width: 80.0, onSelected: (

Sep 29, 2021

A CustomPaint example where we can draw with different colors and different stroke sizes

A CustomPaint example where we can draw with different colors and different stroke sizes

CustomPaint A CustomPaint example where we can draw with different colors and different stroke sizes. A Flutter application which runs on iOS, Android

Dec 27, 2021

Awesome Flutter Snippets is a collection snippets and shortcuts for commonly used Flutter functions and classes

Awesome Flutter Snippets Awesome Flutter Snippets is a collection of commonly used Flutter classes and methods. It increases your speed of development

Dec 9, 2022

Flutter cloud functions - A sample project demonstrating how to run backend tasks in Flutter

Flutter cloud functions - A sample project demonstrating how to run backend tasks in Flutter

Flutter Cloud Functions A sample project demonstrating how to run backend tasks

Feb 15, 2022

A flutter package from AsurRaa for widgets and utility functions to support mobile departments here.

A flutter package from AsurRaa for widgets and utility functions to support mobile departments here.

sura_flutter A flutter package from AsurRaa for custom widgets and utility functions. Migrate from 0.2.x to 0.3.x BREAKING CHANGE: remove FutureManage

Nov 15, 2022

The project of the empty template with Flutter has built the basic framework to realize the functions of internationalization, theme peeling etc.

The project of the empty template with Flutter has built the basic framework to realize the functions of internationalization, theme peeling etc.

flutter-bloc-app-template 🤖 The project of the empty template with Flutter has built the basic framework to realize the functions of internationaliza

Dec 31, 2022
Owner
Avinaba Dalal
Avinaba Dalal
Receiving ozh's github-colors repository with latest commit of colors.json to Flutter's Color object.

Apply GitHub's languages colours into Flutter's Color object. Receiving ozh's github-colors repository with latest commit of colors.json to Flutter's

Cyrus Chan 1 Jun 6, 2022
A dart package which provides a lot of helpers functions for easy development.

more_functions A dart package which provides a lot of helpers functions for easy development. Installation Add this to your packages pubspec.yaml file

Talat El Beick 0 Dec 5, 2021
Calculator provides simple and advanced mathematical functions in a beautifully designed app.

Hi there, I'm Behruz Hurramov Getting Started $ git clone https://github.com/ariscybertech/aris_calculator.git $ flutter packages get Run the applicat

Behruz Hurramov 3 Jul 7, 2022
Calculator provides simple and advanced mathematical functions in a beautifully designed app.

Adv Calculator See LICENSE A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get y

RAHUL SHARMA 3 Feb 21, 2022
User onboarding library with smooth animation of objects and background colors

SlidingTutorial Cleveroad introduces Sliding Tutorial Library for Flutter Hey guys, hope you haven’t started developing a tutorial for your Flutter ap

Cleveroad 127 Dec 31, 2022
This library provides the easiest and powerful Dart/Flutter library for Mastodon API 🎯

The Easiest and Powerful Dart/Flutter Library for Mastodon API ?? 1. Guide ?? 1.1. Features ?? 1.2. Getting Started âš¡ 1.2.1. Install Library 1.2.2. Im

Mastodon.dart 55 Jul 27, 2023
A Flutter color palette with eyedropper, HSL, RGB and Material colors

Cyclop A flutter colorpicker with an eyedropper tool. Works on mobile, desktop & web ( CanvasKit) Demo Desktop & tablet Mobile Material HSL RVB Custom

Erick Ghaumez 106 Oct 17, 2022
A Flutter color palette with eyedropper, HSL, RGB and Material colors

Cyclop A flutter colorpicker with an eyedropper tool. Works on mobile, desktop & web ( CanvasKit) Demo Desktop & tablet Mobile Material HSL RVB Custom

Erick Ghaumez 107 Jan 5, 2023
An extended version of Flutter Colors with more swatches and more flexibility to generate your own custom swatch.

Colours An extended version of Flutter Colors with more swatches and more flexibility to generate your own custom swatch. Getting Started In your flut

Salman S 4 Nov 23, 2021
An Android and iOS game about colors made using Flutter.

Random Color An Android and iOS game. A color is display on the screen and then the player has to pick a color that is the most similar to the one dis

Loïc H. 4 Nov 21, 2022