Created
January 20, 2020 15:03
-
-
Save iamEtornam/8beafa8099399ba2af194197af1d3507 to your computer and use it in GitHub Desktop.
converts color code to Hex color code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```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