mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
19 lines
441 B
Dart
19 lines
441 B
Dart
import 'dart:convert';
|
|
|
|
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);
|
|
}
|
|
|
|
Uint8List get uint8List => Uint8List.fromList(utf8.encode(this));
|
|
}
|