10 lines
280 B
Dart
10 lines
280 B
Dart
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
Color darken(Color color, [double amount = .1]) {
|
||
|
assert(amount >= 0 && amount <= 1);
|
||
|
|
||
|
final hsl = HSLColor.fromColor(color);
|
||
|
final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
|
||
|
|
||
|
return hslDark.toColor();
|
||
|
}
|