Search packages, repositories and app categories

Package detailsv1.1.1

strcolor

Flutter package to convert color names to Color in Flutter. Offers a handful way to use colors by their names instead of using Colors constants.

30-day downloads
24
Likes
25
Pub points
30

Install package

flutter pub add strcolor

Package Overview

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

strcolor is a Flutter package that enables developers to convert color names into Color objects using simple string inputs. Instead of relying on predefined Colors constants, it allows intuitive color naming (e.g., 'red', 'blue', 'purple') for easier and more readable code. The package supports a wide range of common color names and simplifies color management in UI design. It’s lightweight and ideal for projects where dynamic or human-readable color references are preferred.

Use cases

  • Quick color assignment by name
  • Dynamic theme customization
  • Simplifying UI color definitions
  • Reducing reliance on Colors constants
  • Enhancing code readability with named colors

Key features

  • Supports common color names
  • Easy string-to-Color conversion
  • Lightweight and minimal dependency
  • No need for complex color definitions
  • Works seamlessly in Flutter widgets

Suitable for

  • Beginner Flutter developers
  • Projects with frequent color changes
  • UI prototyping
  • Apps using dynamic color schemes
  • Developers preferring readable color syntax

Considerations

  • Limited to predefined color names
  • Does not support custom or hex color strings
  • No runtime error handling for invalid names
  • Not suitable for advanced color manipulation
  • Requires careful naming to avoid ambiguity

Original README

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

strcolor

Dart Pub

Description

Flutter package to convert color names to Color in Flutter.

Offers a handful way to use colors using their names instead of using Colors constants.

It is specialy useful when you need to place color in a component comming dynamically from server.

All Flutter Colors constants supported.

Hexa Colors supported.

Getting Started

In your flutter project add the dependency:

dependencies:
  ...  
  strcolor: ^1.1.1

Usage example

import 'package:strcolor/strcolor.dart';

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(        
        primarySwatch: "purple".color(), // write the color name. When you receive dynamic color name from server this is much more useful.                
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

Dart Pub

strcolor

Author

2020 brworkit.

License

MIT License.

Categories

Source repository

Projects using this package

No data available yet.