Skip to content

Commit 977e98b

Browse files
committed
v1.0.1
1 parent b0fb0f0 commit 977e98b

File tree

5 files changed

+21
-34
lines changed

5 files changed

+21
-34
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.1
2+
3+
Added `color` argument and `showGrid` now defaults to false.
4+
15
## 1.0.0
26

37
Init.

lib/github_identicon.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@ class GitHubIdenticon extends StatelessWidget {
88
final String seed;
99
final double size;
1010
final bool showGrid;
11+
final Color? color;
1112

1213
/// Creates a GitHub-style identicon widget
1314
///
1415
/// [seed] : Unique identifier for the avatar
1516
/// [size] : Display size in pixels
16-
/// [showGrid] : Whether to display grid lines (default: true)
17+
/// [showGrid] : Whether to display grid lines (default: false)
18+
/// [color] : Optional color for the identicon. If it's null, color is generated from hash.
1719
const GitHubIdenticon({
1820
super.key,
1921
required this.seed,
2022
required this.size,
21-
this.showGrid = true,
23+
this.showGrid = false,
24+
this.color,
2225
});
2326

2427
@override
@@ -29,6 +32,7 @@ class GitHubIdenticon extends StatelessWidget {
2932
seed: seed,
3033
size: size,
3134
showGrid: showGrid,
35+
color: color,
3236
).generate(),
3337
builder: (context, snapshot) {
3438
if (snapshot.connectionState == ConnectionState.done &&

lib/github_identicon_generator.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ class GitHubIdenticonGenerator {
99
final String seed;
1010
final double size;
1111
final bool showGrid;
12+
final Color? color;
1213

1314
/// Creates a GitHub identicon generator
1415
///
1516
/// [seed] : Unique identifier for the avatar
1617
/// [size] : Output image size in pixels
17-
/// [showGrid] : Whether to display the 5x5 grid lines (default: true)
18+
/// [showGrid] : Whether to display the 5x5 grid lines (default: false)
19+
/// [color] : Optional color for the identicon. If it's null, color is generated from hash.
1820
GitHubIdenticonGenerator({
1921
required this.seed,
2022
required this.size,
21-
this.showGrid = true,
23+
this.showGrid = false,
24+
this.color,
2225
});
2326

2427
/// Generates the identicon as a UI Image
@@ -27,9 +30,10 @@ class GitHubIdenticonGenerator {
2730
final digest = md5.convert(bytes);
2831
final hashHex = digest.toString();
2932

30-
final color = Color(
31-
0xFF000000 | int.parse(hashHex.substring(0, 6), radix: 16),
32-
);
33+
final Color useColor =
34+
(color != null)
35+
? color!
36+
: Color(0xFF000000 | int.parse(hashHex.substring(0, 6), radix: 16));
3337

3438
const gridSize = 5;
3539
final cellSize = (size / gridSize).floor();
@@ -71,7 +75,7 @@ class GitHubIdenticonGenerator {
7175
}
7276
}
7377

74-
final paint = ui.Paint()..color = color;
78+
final paint = ui.Paint()..color = useColor;
7579

7680
for (int y = 0; y < gridSize; y++) {
7781
for (int x = 0; x < (gridSize / 2).ceil(); x++) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: github_identicon
22
description: Github flavor Identicons for Dart&Flutter.
3-
version: 1.0.0
3+
version: 1.0.1
44
repository: https://github.com/RewLight/github_identicon
55

66
environment:

0 commit comments

Comments
 (0)