Skip to content
pubscout

string_to_color

2.0.0, released 4 years ago by hirantha.xyz

Convert strings to colors, hex strings, or hex integers in Dart and Flutter.

WASM-ready
$ flutter pub add string_to_color
Source repository

What it does

Provides utility methods to deterministically convert any input string into a Flutter Color object, a hex color string, or a hex color integer.

AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to generate consistent avatar background colors based on user names or IDs.
  • You want to map arbitrary string tags to distinct colors automatically.

Skip it when

  • You need a robust design system with predefined, curated color palettes.
  • You require complex color manipulation, blending, or contrast calculation features.

Strengths

  • Extremely simple API for converting strings to colors
  • Supports multiple return types (Color object, hex string, hex int)

Weaknesses

  • Very limited scope with only basic string-to-color functions
  • Lacks advanced customization for color generation algorithms

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0

not documented

import 'dart:ui';
import 'package:string_to_color/string_to_color.dart';

Color color = ColorUtils.stringToColor("name");
String hexColor = ColorUtils.stringToHexColor("name");
int hexInt = ColorUtils.stringToHexInt("name");

Alternatives

Packages that do the same job and could replace string_to_color.

  • fraction

    Create, parse, and perform arithmetic operations with fractions and mixed fractions.

  • bidi

    Converts logical RTL strings to their visual representation using the Unicode Bidirectional Algorithm.

  • extension_utils

    Dart and Flutter extension library for strings, collections, dates, numbers, and colors.

  • kartal

    Collection of Dart and Flutter extensions for context, primitive variables, and common utilities.