패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.2.3

eo_color

Material Design 표준의 색상 팔레트와 스와치를 객체 지향적으로 우아하게 구현한 것; Flutter 내장 색상의 대안.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
237
좋아요
21
Pub 점수
150

패키지 설치

flutter pub add eo_color

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

eo_color는 Flutter 애플리케이션에서 Material Design 색상 팔레트와 스위치를 관리하는 데 있어 우아하고 객체 지향적인 접근 방식을 제공합니다. Flutter 내장 색상의 깔끔한 대안으로, 표준화된 색상 테마에 구조적 접근을 가능하게 하여 가독성과 유지보수성을 향상시킵니다. 이 패키지는 모든 주요 플랫폼을 지원하며 기존 프로젝트에 원활하게 통합됩니다. 더 체계적이고 확장 가능한 색상 처리 방법을 원하는 개발자를 위해 설계되었으며, UI 일관성과 개발자 경험을 향상시킵니다.

사용 사례

  • 사용자 정의 테마 개발
  • Material Design 준수
  • 다양한 플랫폼 간 일관된 컬러 관리
  • UI 컴포넌트 스타일링
  • 디자인 시스템 구현

주요 기능

  • 객체 지향 색상 팔레트 구조
  • 완전한 Material Design 색상 지원
  • 크로스 플랫폼 호환성
  • 깨끗하고 읽기 쉬운 API
  • 확장 가능한 색 정의

적합한 대상

  • Material Design를 사용하는 Flutter 개발자
  • 확장 가능한 디자인 시스템을 구축하는 팀
  • 일관된 색상 처리가 필요한 프로젝트
  • OOP 접근 방식을 선호하는 개발자
  • 다중 플랫폼을 대상으로 하는 앱

고려 사항

  • Material Design 색채 이론에 대한 이해 필요
  • 패키지 크기가 약간 증가할 수 있습니다
  • 최신 플러터 버전의 동적 색상 테마의 대체가 아님

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

EO-Color logo

EO principles respected here DevOps By Rultor.com

pub license

build codecov CodeFactor Grade style: lint Hits-of-Code

Contents

Overview

EO-Color is an Elegant, Object-oriented implementation of the Material Design color palettes and swatches — as well as a color framework!

It is intended to be used as:

  • an alternative to Flutter's built-in colors.
  • a base framework for more specific color packages.

A key benefit of EO-Color is to improve the source code readability and maintainability by providing declarative interfaces.

The use of obscure numeric indexes such as 100, 200…800, 900 to select the shade of a color has been replaced by a more user-friendly approach: the use of adverbs (ultra, very, bit, etc.) and adjectives (light, dark, etc.).

For example, to get the primary shade of grey, simply declare Grey(). Likewise, there are commands for retrieving shades of grey that are either lighter or darker than the primary shade.

  • lighter shades: Grey.bitLighter(), Grey.lighter(), Grey.light(), Grey.veryLight(), or Grey.ultraLight() for the lightest shade of grey.
  • darker shades: Grey.bitDarker(), Grey.darker(), Grey.dark(), or Grey.veryDark() for the darkest shade.

With the exception of black and white, the same command patterns (light, lighter, dark, etc.) also apply to all other colors

Getting Started

Like any other object-oriented package, this one uses interfaces to define concepts such as the color palette, color swatch and color gradient; therefore, the three main interfaces are Palette, Swatch and Gradient.

Palette interface

The Palette interface represents color palettes from which a color can be selected.

Typically, subclasses of the Palette interface provide named constructors by which the desired color is selected — to be retrieved later using the color property.

For instance, the command Blue() retrieves the primary shade of blue, and it is equivalent to the Flutter command Colors.blue.shade500. Similarly, Blue.veryLight() is equivalent to Colors.blue.shade50; Blue.veryDark(), to Colors.grey.shade900; and so on.

The code snippet below demonstrates how to build a bluish Flutter Container widget using the Blue color class.

Code snippet:

/// Builds a bluish container.
@override
Widget build(BuildContext context) {
  return Container(color: const Blue().color);
}

All Material Design colors — along with their respective accent-colors — have been implemented.

For a complete list of colors with detailed information (hex codes, indexes, opacity, etc.), see:

Numeric indexes vs. Named constructors

The table below contains the relationship between the Material Design indexes (100, 200…800, 900) and the named constructors of the color classes.

  • Note:
    • The "Normal" column refers to classes that represent non-accent colors such as Amber, Green, Red, etc.
    • On the other hande, the "Accent" column refers to classes that represent accent colors such as AmberAccent, GreenAccent, RedAccent, and so on.
    • Finally, "()" refers to the default constructor, which in turn represents the primary shade of the color class it belongs to.
Index Normal Accent
50 ultraLight
100 veryLight light
200 light ()
300 lighter
400 bitLighter darker
500 ()
600 bitDarker
700 darker dark
800 dark
900 veryDark

Swatch interface

The Swatch interface represents a collection of related colors such as:

  • shades of grey;
  • the color gradient of a brand;
  • a user's preferred colors.

Its single property colors retrieves several colors at once as an Iterable<Color> object.

Except for the White and Black classes, there is always a corresponding "plural" class for each color class — accent colors included — that implements the Swatch interface. For example, the command Greys().colors retrieves 10 shades of grey; the higher the index, the darker the color.

For a red color gradient:

/// a color gradient of 10 shades of red.
final Iterable<Color> theReds = Reds().colors;

For a complete list of color swatches:

Swatch in action

The following code provides a fully working example. It creates a rectangle widget filled with a color gradient provided by the swatch instance.

import 'package:eo_color/swatches.dart';
import 'package:flutter/material.dart';

/// Rectangle filled with a gradient of ten shades of a Material Design color.
class RectGradient extends StatelessWidget {
  /// Rectangle filled with the given color swatch.
  const RectGradient(Swatch swatch, {Key? key})
      : _swatch = swatch,
        super(key: key);

  /// Rectangle filled with ten shades of grey.
  const RectGradient.grey({Key? key}) : this(const Greys(), key: key);

  // Material Design color swatch.
  final Swatch _swatch;

  @override
  Widget build(BuildContext context) {
    return Container(
      height: kToolbarHeight / 2,
      decoration: BoxDecoration(
        gradient: LinearGradient(
          end: Alignment.bottomLeft,
          begin: Alignment.topRight,
          colors: _swatch.colors.toList(growable: false),
        ),
      ),
    );
  }
}

Gradient interface

It represents a range of position-dependent colors, usually used to fill a region. The colors produced by a gradient vary continuously with position, producing smooth color transitions.

While the Swatch interface retrieves an iterable<Colors> object, subclasses of Gradient retrieves a List<Colors>, which makes them better suited for dealing with Flutter's gradient APIs — these APIs almost always expects a List<Color> object as the parameter rather than an Iterable<Color> object.

For Material Design color gradients, use the GradOf class, which in turn implements the Gradient interface. Another example of a Gradient implementation is the abstract class GradientImmut, which retrieves immutable List<Colors> objects.

For a complete list of gradients:

Demo application

The demo application provides a fully working example, focused on demonstrating exactly three color palettes in action: BlueGrey, Grey, and Brown. You can take the code in this demo and experiment with it.

To run the demo application:

git clone https://github.com/dartoos-dev/eo_color.git
cd eo_color/example/
flutter run -d chrome

This should launch the demo application on Chrome in debug mode.

Demo-App

Contribute

Contributors are welcome!

  1. Open an issue regarding an improvement, a bug you noticed, or ask to be assigned to an existing one.
  2. If the issue is confirmed, fork the repository, do the changes on a separate branch and make a Pull Request.
  3. After review and acceptance, the Pull Request is merged and closed.

Make sure the command below passes before making a Pull Request.

  flutter analyze && flutter test

References

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트