Search packages, repositories and app categories

Package detailsv0.0.1

color_hex

Flutter package to convert hex String to Color() , and Color() to hex String

AndroidiOSWebmacOSWindowsLinux
30-day downloads
766
Likes
6
Pub points
140

Install package

flutter pub add color_hex

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The color_hex package is a lightweight Flutter utility that enables seamless conversion between hexadecimal color strings and Flutter's Color objects. It simplifies color handling in apps by providing straightforward methods to parse hex codes (like '#FF5733') into Color instances and to convert Color objects back into their hex string representations. Ideal for dynamic theming, color pickers, or any scenario requiring color manipulation from text input.

Use cases

  • Converting hex strings to Color objects
  • Generating hex strings from Color instances
  • Dynamic theme customization
  • Color picker integration
  • Styling UI elements with hex values
  • Saving and loading color preferences

Key features

  • Simple hex to Color conversion
  • Color to hex string serialization
  • Supports alpha channel in hex
  • Minimal dependency footprint
  • Cross-platform compatibility
  • Clean, intuitive API

Suitable for

  • Developers working with color themes
  • Apps using color pickers
  • Projects requiring hex-based color storage
  • UI/UX designers implementing color logic
  • Flutter apps needing consistent color handling

Considerations

  • Does not validate hex format input
  • No built-in support for named colors
  • Limited to basic color string operations
  • Requires manual error handling for invalid hex
  • Not suitable for complex color manipulation

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

color_hex:

A package helps you to convert Hex color to Color() , and convert Color() to hex color

# 👨‍💻 Developed by:

profile

Nasr Al-Rahbi @abom_me

👨🏻‍💻 Find me in :

Twitter Instagram LinkedIn Stack Overflow



🔥 Get Started :

Pubspec changes:

      dependencies:
        color_hex: <last_verison>
How to use it?

you can add it to your text or color as extension like this :

  Color color=Colors.deepPurple;
  String hex="#000000";
  /// here we convert the hex to color and the color to hex 
Text(color.convertToHex.hex,style: TextStyle(color: hex.convertToColor),),

Another way you can convert it using the function :

  Color color=Colors.deepPurple;
  String hex="#000000";
InkWell(
onTap: (){
/// Convert HexColor to Color()
print(hexToColor(hex).toString());
/// Convert Color() to HexColor
print(colorToHex(color).hex);
print(colorToHex(color).color);
},
child:Text("click to convert",style: TextStyle(
/// here we convert the color to hex then we convert the hex to color again
color: color.convertToHex.hex!.convertToColor
),)
)

Categories

Source repository

Projects using this package

No data available yet.