when developing app with flutter, I want to define some commonly used styles
the code is as follows:
import "package:flutter/material.dart";
class AppStyle {
static Color colorRed = const Color(0xffe04f5f);
static Color colorWhite = const Color(0xffffffff);
static Color colorGreen = const Color(0xff1abc9c);
}
now, to define the style of a list title, add a line
static TextStyle listRowTitle = const TextStyle(fontSize: 20.0, color: colorGreen);
if you write this above, there will be a problem here in colorGreen. The error message is
.[dart] Invalid constant value.
[dart] Arguments of a constant creation must be constant expressions.
Color colorGreen
if, there is no problem changing colorGreen to Color (0xff1abc9c)!
static TextStyle listRowTitle = const TextStyle(fontSize: 20.0, color: Color(0xff1abc9c));
I have been google for a long time, but I still can"t find the answer. Which god can explain it to me?