2023-10-23 17:44:03 +05:30
2023-10-23 17:44:03 +05:30
2023-08-09 00:05:19 +05:30
2023-10-09 21:24:39 +05:30
2023-10-03 12:35:06 +05:30
2023-10-09 21:24:39 +05:30

Logo
Catppuccin for Dart

 

Get started with example/main.dart

Installation

To use Catppuccin in a Dart / Flutter project, you can follow these steps:

  1. Add Catppuccin to Your pubspec.yaml File: Open your pubspec.yaml file and add the following line under the dependencies section:
    dependencies:
        # ...
        catppuccin: ^0.2.2
        # ...
    
  2. After adding catppuccin to your pubspec.yaml file, run the following command in your terminal to fetch the packages:
    flutter pub get
    
    If you are not building a flutter app, you can use:
    dart pub get
    

Usage

import 'package:catppuccin/src/catppuccin_base.dart';

void main() {
  List<int> blue = variants[FlavorNames.mocha]![FlavorColorKeys.blue]!.rgb;
  print(blue); //[137, 180, 250]
}

  • FlavorColorKeys and FlavorNames are enums that are used to represent fixed sets of color keys and flavor names, respectively.
  • ColorInfo encapsulates color information, including RGB, hex, and HSL values.
  • variants is a map that associates flavor names FlavorNames with color information ColorInfo for various color keys FlavorColorKeys.

Tips for flutter projects

Use the below code snipet to convert the value field of the map to the Color data structure of the flutter library.

import 'package:catppuccin/catppuccin.dart';
import 'package:flutter/material.dart';

Map<FlavorColorKeys, Color> convertColorInfoMapToColorMap(
    Map<FlavorColorKeys, ColorInfo> colorInfoMap) {
  return colorInfoMap.map((key, colorInfo) => MapEntry(key,
      Color.fromRGBO(colorInfo.rgb[0], colorInfo.rgb[1], colorInfo.rgb[2], 1)));
}

Map<FlavorColorKeys, Color> mocha =
    convertColorInfoMapToColorMap(variants[FlavorNames.mocha]!);

Color pink = mocha[FlavorColorKeys.pink]!;

Contributing

If you are looking to contribute, please read through our CONTRIBUTING.md first!

💝 Thanks to

 

Copyright © 2022-present Catppuccin Org

Description
No description provided
Readme MIT 823 KiB
Languages
Dart 74.5%
CMake 16.5%
C++ 7.7%
C 1.3%