hexify 0.0.1
hexify: ^0.0.1 copied to clipboard
A powerful and flexible Flutter package for color manipulation and gradient creation. Hexify simplifies the process of working with hex colors, RGBO values, and gradients, making it easy for beginners [...]
Hexify #
Hexify is a powerful, flexible, and user-friendly Flutter package designed to simplify color manipulation and gradient creation. Whether you're a beginner or an experienced developer, Hexify makes working with colors in Flutter a breeze, allowing you to create stunning and dynamic color schemes with minimal effort.
Why Choose Hexify? #
π Simplicity at Its Core #
Hexify takes the complexity out of color manipulation. With just a single function call, you can convert hex codes, create gradients, and apply sophisticated color transformations. No more juggling multiple color utility functions or dealing with complex color math!
π¨ Versatile Color Handling #
From simple hex code conversions to complex gradient generations, Hexify has got you covered. It seamlessly handles hex codes (with or without '#'), RGBO values, and even creates linear and radial gradients on the fly.
π Flexible API #
Designed with flexibility in mind, Hexify's API allows you to do as much or as little as you need. Need a quick color from a hex code? One line of code. Want to create a complex three-color gradient with custom stops and transformations? Hexify scales to your needs.
π Intelligent Defaults #
While offering a wide range of customization options, Hexify also provides smart defaults. This means you can get great results with minimal configuration, perfect for rapid prototyping or when you need a quick color solution.
π Robust Error Handling #
Hexify includes comprehensive error checking and provides meaningful error messages. This helps catch and diagnose issues early in the development process, saving you time and headaches.
Features #
- π Easy conversion of hex color codes to Flutter
Colorobjects - π Effortless creation of linear and radial gradients
- π’ Support for RGBO color values
- π³ Apply opacity and shading to colors with ease
- π§ Flexible API for various color manipulation scenarios
- β‘ Optimized for performance
Installation #
Adding Hexify to your project is simple. Just add this line to your package's pubspec.yaml file:
dependencies:
hexify: ^0.0.1
Then run:
$ flutter pub get
And that's it! You're ready to start using Hexify in your project.
Usage #
Using Hexify is straightforward. Start by importing the package:
import 'package:hexify/hexify.dart';
Quick Start: Basic Color Creation #
Creating a color from a hex code is as simple as:
Color myColor = Hexify(colorCode: '#FF5733');
// or
Color myColor = Hexify(colorCode: 'FF5733');
Hexify is flexible with hex code input. You can use the '#' symbol or omit it:
// Both of these are valid and will produce the same color
Color myColor1 = Hexify(colorCode: '#FF5733');
Color myColor2 = Hexify(colorCode: 'FF5733');
This flexibility allows you to use hex codes in the format that's most convenient for your project or coding style.
Gradient Magic: Create Stunning Gradients #
With Hexify, creating gradients is a breeze. Here's how you can create a beautiful linear gradient:
LinearGradient myGradient = Hexify(
gradientType: HexifyGradientType.LinearGradient,
firstColor: '#FF5733',
secondColor: '#3498DB'
);
// or
LinearGradient myGradient = Hexify(
gradientType: HexifyGradientType.LinearGradient,
firstColor: 'FF5733',
secondColor: '3498DB'
);
Want a radial gradient instead? Just change the gradientType:
RadialGradient myRadialGradient = Hexify(
gradientType: HexifyGradientType.RadialGradient,
firstColor: '#FF5733',
secondColor: '#3498DB',
radius: 0.8
);
// or
RadialGradient myRadialGradient = Hexify(
gradientType: HexifyGradientType.RadialGradient,
firstColor: 'FF5733',
secondColor: '3498DB',
radius: 0.8
);
Advanced Color Manipulation: Opacity and Shading #
Hexify makes it easy to apply opacity and shading to your colors:
// Create a color with 50% opacity
Color semiTransparentColor = Hexify(colorCode: '#FF5733', opacity: 0.5);
// or
Color semiTransparentColor = Hexify(colorCode: 'FF5733', opacity: 0.5);
// Create a darker shade of the color
Color darkerShade = Hexify(colorCode: '#FF5733', shade: 0.7);
// or
Color darkerShade = Hexify(colorCode: 'FF5733', shade: 0.7);
RGBO Support: More Ways to Define Colors #
Prefer working with RGBO values? Hexify has got you covered:
Color myRgboColor = Hexify(colorCode: '255, 87, 51, 0.8');
Real-World Examples #
Creating a Dynamic Theme #
Hexify shines when creating dynamic themes. Here's a quick example:
class MyTheme {
static Color primaryColor = Hexify(colorCode: '#3498DB');
// or
static Color primaryColor = Hexify(colorCode: '3498DB');
static Color accentColor = Hexify(colorCode: '#E74C3C');
// or
static Color accentColor = Hexify(colorCode: 'E74C3C');
static LinearGradient backgroundGradient = Hexify(
gradientType: HexifyGradientType.LinearGradient,
firstColor: '#3498DB',
secondColor: '#E74C3C',
begin: Alignment.topLeft,
end: Alignment.bottomRight
);
// or
static LinearGradient backgroundGradient = Hexify(
gradientType: HexifyGradientType.LinearGradient,
firstColor: '3498DB',
secondColor: 'E74C3C',
begin: Alignment.topLeft,
end: Alignment.bottomRight
);
}
Custom Painter with Hexify #
Hexify integrates seamlessly with Flutter's CustomPainter:
class MyCustomPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..shader = Hexify(
gradientType: HexifyGradientType.RadialGradient,
firstColor: '#FF5733',
secondColor: '#3498DB',
radius: 0.5
).createShader(Rect.fromLTWH(0, 0, size.width, size.height));
// or
final paint = Paint()
..shader = Hexify(
gradientType: HexifyGradientType.RadialGradient,
firstColor: 'FF5733',
secondColor: '3498DB',
radius: 0.5
).createShader(Rect.fromLTWH(0, 0, size.width, size.height));
canvas.drawCircle(Offset(size.width / 2, size.height / 2), size.width / 3, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}
API Reference #
Hexify Function #
The main Hexify function is your Swiss Army knife for color manipulation. It accepts a wide range of parameters:
colorCode: String (hex code with or without '#', or RGBO value)opacity: double (0.0 to 1.0 or 1 to 100)gradientType: HexifyGradientType (LinearGradient or RadialGradient)firstColor,secondColor,thirdColor: String (hex codes with or without '#' for gradients)firstColorShade,secondColorShade,thirdColorShade: double (0.0 to 1.0)shade: double (0.0 to 1.0)opacityOfFirstColor,opacityOfSecondColor,opacityOfThirdColor: double (0.0 to 1.0)begin,end: AlignmentGeometry (for LinearGradient)stops: ListtileMode: TileModetransform: GradientTransformradius: double (for RadialGradient)center,focal: AlignmentGeometry (for RadialGradient)focalRadius: double (for RadialGradient)
For detailed usage of each parameter, refer to the API documentation or the source code.
Performance Considerations #
Hexify is designed with performance in mind. It uses efficient algorithms for color conversion and gradient creation, ensuring that your app remains snappy even when handling complex color operations.
Contributing #
We believe in the power of community! If you have ideas for improvements or have found a bug, we'd love to hear from you. Here's how you can contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
We appreciate all contributions, big or small!
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Support #
Running into issues or have questions? We're here to help! Please open an issue on the GitHub repository.
Acknowledgements #
- A big thank you to all the contributors who have helped shape Hexify.
- Special thanks to the Flutter and Dart teams for providing an excellent framework and language.
- Inspired by the needs of developers who want an easier way to work with colors in Flutter.
What's Next? #
We're constantly working to improve Hexify and add new features. Stay tuned for updates, and feel free to suggest features you'd like to see in future versions!
Happy coding with Hexify! π¨β¨