import 'dart:convert'; import 'dart:math'; import 'dart:ui'; import 'package:flutter/material.dart'; class Utilities { static const Color BLACK = Color.fromARGB(255, 0, 0, 0); static const Color WHITE = Color.fromARGB(255, 255, 255, 255); static const Color GREY = Color.fromARGB(255, 80, 80, 80); static String toRGBA(Color color) { return 'rgba(${color.r},${color.g},${color.b},${color.a / 255})'; } static Color textColor(Color color) { if (color.computeLuminance() > 0.75) { return BLACK; } else if (color.computeLuminance() > 0.25) { return GREY; } else { return WHITE; } } static String generateRandom([int length = 16]) { final Random _random = Random.secure(); var values = List.generate(length, (i) => _random.nextInt(256)); return base64Url.encode(values).substring(0, length); } static bool truthful(value) { if (value == null) { return false; } if (value == true || value == 'true' || value == 1 || value == '1' || value.toString().toLowerCase() == 'yes') { return true; } return false; } }