Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Feb 13, 2025
1 parent bd545c6 commit b1b81cd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions material_3_demo/lib/color_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ class _ColorBoxState extends State<ColorBox> {
// Copy color as hex to clipboard
final c = widget.color;

String hex = '#';
hex += colorChannelToHex(c.r);
hex += colorChannelToHex(c.g);
hex += colorChannelToHex(c.b);
final hex =
'#${_colorChannelToHex(c.r)}'
'${_colorChannelToHex(c.g)}'
'${_colorChannelToHex(c.b)}';

final data = ClipboardData(text: hex);
await Clipboard.setData(data);
Expand All @@ -88,9 +88,9 @@ class _ColorBoxState extends State<ColorBox> {
),
);
}
}

String colorChannelToHex(double value) {
final intVal = (value * 255).round();
return intVal.toRadixString(16).padLeft(2, '0');
}
String _colorChannelToHex(double value) {
final intVal = (value * 255).round();
return intVal.toRadixString(16).padLeft(2, '0');
}

0 comments on commit b1b81cd

Please sign in to comment.