ts-tat/lib/utils/colorOpcity.dart
2025-04-19 17:40:19 +05:30

14 lines
386 B
Dart

import 'package:flutter/material.dart';
extension ColorOpacityExtension on Color {
Color withOpacitySafe(double opacity) {
final int alpha = (opacity * 255).round().clamp(0, 255);
return Color.fromARGB(
alpha, // alpha value should be an int
this.r.toInt(), // red channel
this.g.toInt(), // green channel
this.b.toInt(), // blue channel
);
}
}