How to convert Flutter color to string and back to a color

前端 未结 4 1622
小蘑菇
小蘑菇 2020-12-06 02:23

I am converting a Color to a String. I am then converting the Color to a String. Unfortunately when I want to convert it back into a Color the operation fails:

<         


        
4条回答
  •  感情败类
    2020-12-06 02:45

    Use the following code to get hex value of the color.

    Color color = Colors.red;
    var hexCode = '#${color.value.toRadixString(16).substring(2, 8)}';
    

提交回复
热议问题