Skip to content
Snippets Groups Projects
Select Git revision
  • 4871ae1b3b8b8c70bd3ba11821dd1a3af4edad39
  • master default protected
  • 21-add-onlongpress-with-popup-on-parameters
  • 23-center-vertically-buttons
  • 30-highlight-bin-when-selecting-disabled-item
  • 1.0.7 protected
  • 1.0.6 protected
  • 1.0.5 protected
  • 1.0.4 protected
  • 1.0.3 protected
  • 1.0.2 protected
  • 1.0.0 protected
  • 0.9.1 protected
  • 0.9.0 protected
  • 0.8.4 protected
  • 0.8.3 protected
  • 0.8.2 protected
  • 0.8.1 protected
  • 0.8.0 protected
  • 0.7.0 protected
  • 0.6.1 protected
  • 0.6.0 protected
  • 0.5.0 protected
  • 0.4.0 protected
  • 0.3.0 protected
25 results

color_extensions.dart

Blame
  • color_extensions.dart 752 B
    import 'dart:ui';
    
    extension ColorExtension on Color {
      Color darken([int percent = 40]) {
        assert(1 <= percent && percent <= 100);
        final value = 1 - percent / 100;
        return Color.from(
          alpha: a,
          red: r * value,
          green: g * value,
          blue: b * value,
        );
      }
    
      Color lighten([int percent = 40]) {
        assert(1 <= percent && percent <= 100);
        final value = percent / 100;
        return Color.from(
          alpha: a,
          red: r + ((1 - r) * value),
          green: g + ((1 - g) * value),
          blue: b + ((1 - b) * value),
        );
      }
    
      Color avg(Color other) {
        return Color.from(
          alpha: (a + other.a) / 2,
          red: (r + other.r) / 2,
          green: (g + other.g) / 2,
          blue: (b + other.b) / 2,
        );
      }
    }