Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class OverlayElevation {
  4. static const e1 = OverlayElevation._(0.05);
  5. static const e2 = OverlayElevation._(0.07);
  6. static const e3 = OverlayElevation._(0.08);
  7. static const e4 = OverlayElevation._(0.09);
  8. static const e6 = OverlayElevation._(0.11);
  9.  
  10. static const values = [e1, e2, e3, e4, e6];
  11.  
  12. const OverlayElevation._(this._opacity);
  13.  
  14. final double _opacity;
  15.  
  16. int get ordinal => values.indexOf(this);
  17.  
  18. Color merge(Color fg, Color bg) {
  19. return Color.alphaBlend(fg.withOpacity(_opacity), bg);
  20. }
  21. }
  22.  
  23. void foo() {
  24. blah(OverlayElevation.e4);
  25. }
  26.  
  27. void blah(OverlayElevation e) {
  28. final color = e.merge(Colors.red, Colors.blue);
  29. print(color.value.toRadixString(16));
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement