Skip to content

Instantly share code, notes, and snippets.

@iamEtornam
Created January 20, 2020 15:03
Show Gist options
  • Save iamEtornam/8beafa8099399ba2af194197af1d3507 to your computer and use it in GitHub Desktop.
Save iamEtornam/8beafa8099399ba2af194197af1d3507 to your computer and use it in GitHub Desktop.
converts color code to Hex color code
```dart
import 'package:flutter/material.dart';
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));
}
```dart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment