Files
flutter_server_box/lib/core/extension/stringx.dart
lollipopkit 4d06a52e99 new & opt.
- new: support suspend and WOL #172
- opt.: `execWithPwd` when cancel
- opt.: extentions
2023-09-25 18:51:14 +08:00

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));
}