gozap_package.dart 672 B

1234567891011121314151617181920212223242526272829
  1. library gozap_package;
  2. import 'package:flutter/material.dart';
  3. MaterialColor buildMaterialColor(Color color) {
  4. List strengths = <double>[.05];
  5. Map<int, Color> swatch = <int, Color>{};
  6. final int r = color.red, g = color.green, b = color.blue;
  7. for (int i = 1; i < 10; i++) {
  8. strengths.add(0.1 * i);
  9. }
  10. for (var strength in strengths) {
  11. final double ds = 0.5 - strength;
  12. swatch[(strength * 1000).round()] = Color.fromRGBO(
  13. r + ((ds < 0 ? r : (255 - r)) * ds).round(),
  14. g + ((ds < 0 ? g : (255 - g)) * ds).round(),
  15. b + ((ds < 0 ? b : (255 - b)) * ds).round(),
  16. 1,
  17. );
  18. }
  19. return MaterialColor(color.value, swatch);
  20. }