一个 Flutter 包,可生成动态的浅色和深色配色方案以增强应用主题。它提供了一种简单的方法来创建视觉上吸引人且协调的主题,而无需手动选择颜色。非常适合原型设计或需要多种视觉风格的应用。该包支持多个平台,并通过简单的 API 无缝集成到 Flutter 项目中。配色方案通过算法生成,确保 UI 元素(如背景、文本和按钮)具有和谐与对比度。
适合场景
应用主题原型设计
动态UI主题
应用中的视觉多样性
快速设计迭代
面向可访问性的颜色生成
跨平台主题一致性
主要特点
自动生成浅色和深色配色方案
算法色彩和谐
与 Flutter 的简单集成
支持所有主要平台
可自定义方案生成
一致的用户界面美学
适合对象
UI 设计师寻求快速主题选项
开发可定制的应用程序的开发者
原型设计工具和演示应用
需要多种主题变体的应用程序
强调视觉多样性的项目
使用建议
生成的颜色可能并不总是符合品牌指南
对特定色调选择的控制有限
最适合非关键或实验性主题
需要验证以符合无障碍访问要求
不太适合严格的品牌要求
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Random Color Scheme
Making a coherent Material Design theme is hard. This is a Flutter plugin that generates a random color pallet based on Material Design while respecting WCAG guidelines.
The idea is for you to (temporarily) replace your ColorScheme() with a randomColorSchemeLight() or randomColorSchemeDark().
On each run, hot refresh or hot restart, the app is going to look different. The theme is printed in terminal, so you can easily copy and paste back into your project with the colors that you want to stay.
The interactive sample allows you to see how it works and the reasoning behind:
Usage
In the pubspec.yaml of your flutter project, add the following dependency:
dependencies:random_color_scheme:^VERSION
In your project, just replace the ColorScheme.dark(...) with randomColorSchemeDark().
If you want a light theme, there is a randomColorSchemeLight().
This started in my Color Studio project.
I started looking at the Material Design Guidelines on color for both light and dark theme.
After extracting some colors (like the Primary, Secondary and Owl Study), I decided to see how similar were they, in what range are they and how they behave together.
Then, I used HSLuv with a random number generator and rules detected from my observation. The final adjustments were made when tweaking the sample.
HSLuv is great because only the Lightness attribute affects WCAG calculated contrast, so all themes are guaranteed to pass
a minimum accessibility threshold.
Seed: an integer which guarantees the random function is always going to have the same output (i.e., the same ColorScheme).
It is optional.
Reporting Issues
If you have any suggestions or feedback, issues and pull requests are welcome.
You can report here.
License
Copyright 2020 Bernardo Ferrari
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.