When developing app with flutter, i want to define some common 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, i want to define a new style.
static TextStyle listRowTitle = const TextStyle(fontSize: 20.0, color: colorGreen);
If you write to the above, then colorGreen will have a problem here. The wrong message is
[dart] Invalid constant value.
[dart] Arguments of a constant creation must be constant expressions.
Color colorGreen
If you change colorGreen to Color (0xff1abc9c), there is no problem!
static TextStyle listRowTitle = const TextStyle(fontSize: 20.0, color: Color(0xff1abc9c));
Ask me to teach me,please!