mirror of
https://github.com/catppuccin/flutter.git
synced 2026-01-09 05:40:56 +08:00

Catppuccin for Dart
Get started with example/main.dart
Installation
To use Catppuccin in a Dart / Flutter project, you can follow these steps:
- Add Catppuccin to Your
pubspec.yamlFile: Open yourpubspec.yamlfile and add the following line under thedependenciessection:dependencies: # ... catppuccin: ^0.2.2 # ... - After adding catppuccin to your
pubspec.yamlfile, run the following command in your terminal to fetch the packages:
If you are not building a flutter app, you can use:flutter pub getdart 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]
}
FlavorColorKeysandFlavorNamesare enums that are used to represent fixed sets of color keys and flavor names, respectively.ColorInfoencapsulates color information, including RGB, hex, and HSL values.variantsis a map that associates flavor namesFlavorNameswith color informationColorInfofor various color keysFlavorColorKeys.
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
Languages
Dart
74.5%
CMake
16.5%
C++
7.7%
C
1.3%