-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Added generateRandomMaterialColor.
- Loading branch information
Showing
6 changed files
with
72 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
part of katana_theme; | ||
|
||
/// Get one at random from the major MaterialColor. | ||
/// | ||
/// Colors specified in [ignoreColors] are excluded. | ||
/// | ||
/// Get a random color based on the value specified in [seed]. | ||
/// | ||
/// 主要なMaterialColorからランダムで一つ取得します。 | ||
/// | ||
/// [ignoreColors]に指定した色は除外されます。 | ||
/// | ||
/// [seed]に指定した値を元にランダムな色を取得します。 | ||
MaterialColor generateRandomMaterialColor({ | ||
List<Color>? ignoreColors, | ||
int? seed, | ||
}) { | ||
ignoreColors ??= []; | ||
const colors = [ | ||
Colors.pink, | ||
Colors.red, | ||
Colors.deepOrange, | ||
Colors.green, | ||
Colors.teal, | ||
Colors.cyan, | ||
Colors.blue, | ||
Colors.indigo, | ||
Colors.blue, | ||
Colors.purple, | ||
Colors.blueGrey, | ||
Colors.brown, | ||
]; | ||
return colors | ||
.where((element) => !ignoreColors.contains(element)) | ||
.toList() | ||
.getRandom(seed) ?? | ||
Colors.red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters