dvd-bnc/monet
一個 Flutter 庫,可在 Android 上使用 monet 取得壁紙顏色,或使用主要色彩產生顏色。
- Stars
- 20
- Forks
- 0
- 最近推送(UTC)
- 2021年8月13日
- 專案狀態
- 未封存
使用的依賴
依賴清單 3 項
- flutter
{"sdk":"flutter"} - flutter_test開發依賴
{"sdk":"flutter"} - flutter_lints開發依賴
^1.0.0
原始 README
以下為英文專案原文快照,最新內容請造訪 GitHub。
展開 / 收合專案 README
Flutter monet
A library to get wallpaper colors using monet on Android or generate them using a primary color.
The Android platform implementation uses MonetCompat to get the colors and to handle older Android versions. The library also provides a dart implementation of kdrag0n monet engine to derive colors from a provided color.
Getting Started
For Android apps targeting version 8.0 and up no setup is required, however if you wish to support lower versions some steps are required.
-
Create a new class, call it however you want (possibly something Application related) and extend
MonetApplication. This is the application class from the example, you can use it as is easily enough.. . . import hrx.plugin.monet.MonetApplication class CustomApplication : MonetApplication() -
Use the new application class in the AndroidManifest. To do so, just add
android:nameto the manifestapplicationentry. This snippet is derived from the example app as before.<application android:name=".CustomApplication" ...> -
(Optional) Request the
READ_EXTERNAL_STORAGEpermission. In some older version of Android sometimes it was required to have theREAD_EXTERNAL_STORAGEpermission in order to get the wallpaper. If you omit said permission, nothing terribly bad will happen as the underlying lib will use default colors, so it will not error out. To add the permission, add<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />to theAndroidManifest
Using the library
You should use MonetProvider to get a working monet implementation.
First of all, get a new instance:
final MonetProvider monet = await MonetProvider.newInstance();
It's recommended to store this instance somewhere accessible in the entire app.
After you've got the instance, you can get the colors by calling getColors
// The color parameter is needed to handle cases where there are no platform colors available, such as unsupported platforms.
final MonetColors colors = monet.getColors(Colors.blue);
Once you got the colors, you can use them as you wish to. MonetColors contains five palettes as required by the monet specification. Each shade is derived from the base color with slight variations. For example, you can get the palette directly derived from the primary color by calling colors.accent1.
final MonetPalette accent1 = colors.accent1;
From the palette you can access a total of 13 shades, varying in lightness. You can use these in combination with a ColorScheme for example.
ColorScheme.light(
secondary: accent1.shade500,
background: accent1.shade200,
surface: accent1.shade100,
);
You can find a simple example on the example folder and some docs on the class definitions themselves