Flutter/Dart: Convert HEX color string to Color?

前端 未结 5 841
醉酒成梦
醉酒成梦 2020-12-10 02:24

Our database has colors saved as a String like \"#AABBCC\" and so I\'m basically looking for a function like this: Color.parseColor(\"#AABBCC\"); f

5条回答
  •  清歌不尽
    2020-12-10 03:11

    A simple string replacement would get it in the right syntax:

    String html_colour = '#AAABBCC';
    String fixed_colour = html_colour.replace(new RegExp(r'#'), '0xFF');
    

    That should do it.

提交回复
热议问题