added frontend
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart' show Colors, Color;
|
||||
|
||||
extension HexColor on Color {
|
||||
/// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#".
|
||||
static Color fromHex(String hexString) {
|
||||
final buffer = StringBuffer();
|
||||
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
|
||||
buffer.write(hexString.replaceFirst('#', ''));
|
||||
return Color(int.parse(buffer.toString(), radix: 16));
|
||||
}
|
||||
}
|
||||
|
||||
extension RiskColor on Color {
|
||||
static const Color noRisk = Colors.transparent;
|
||||
static final Color lowRisk = HexColor.fromHex("#FFFF00");
|
||||
static final Color mediumRisk = HexColor.fromHex("#FF9000");
|
||||
static final Color highRisk = HexColor.fromHex("#FF4000");
|
||||
|
||||
static Color colorForRisk(int value) {
|
||||
if (value == 1) {
|
||||
return lowRisk;
|
||||
} else if (value == 2) {
|
||||
return mediumRisk;
|
||||
} else if (value == 3) {
|
||||
return highRisk;
|
||||
}
|
||||
return noRisk;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user