mirror of
https://github.com/dstark5/Openlib.git
synced 2025-05-19 23:46:29 +08:00
13 lines
365 B
Dart
13 lines
365 B
Dart
// Flutter imports:
|
|
import 'package:flutter/material.dart';
|
|
|
|
extension ColorExtension on String {
|
|
toColor() {
|
|
var hexString = this;
|
|
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));
|
|
}
|
|
}
|