mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-19 22:55:17 +01:00
opt.: settings
This commit is contained in:
@@ -8,6 +8,13 @@ const _interactiveStates = <MaterialState>{
|
||||
};
|
||||
|
||||
extension ColorX on Color {
|
||||
String get toHex {
|
||||
final redStr = red.toRadixString(16).padLeft(2, '0');
|
||||
final greenStr = green.toRadixString(16).padLeft(2, '0');
|
||||
final blueStr = blue.toRadixString(16).padLeft(2, '0');
|
||||
return '#$redStr$greenStr$blueStr';
|
||||
}
|
||||
|
||||
bool get isBrightColor {
|
||||
return getBrightnessFromColor == Brightness.light;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,16 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension StringX on String {
|
||||
/// Format: `#8b2252` or `8b2252`
|
||||
Color? get hexToColor {
|
||||
final hexCode = replaceAll('#', '');
|
||||
final val = int.tryParse('FF$hexCode', radix: 16);
|
||||
if (val == null) {
|
||||
return null;
|
||||
}
|
||||
return Color(val);
|
||||
}
|
||||
|
||||
int get i => int.parse(this);
|
||||
|
||||
Uri get uri {
|
||||
|
||||
Reference in New Issue
Block a user