I am using GetX with Flutter and dynamically change Application theme via standard ThemeData. All is working great for properties within ThemeData.
However, I just implemented Drawer widget and wanted to also theme the 'decoration' property within DrawerHeader (of type BoxDecoration). I wanted to theme the color within BoxDecoration depending on selected theme but it only seems to accept constant. I have not find any way to dynamically change it based on the theme.
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: const <Widget>[
DrawerHeader(
decoration:
BoxDecoration(color: Get.isDarkMode ? Colors.red : Colors.blue),
I get the following error:
The values in a const list literal must be constants. Try removing the keyword 'const' from the list literal.
It relates to the following part:
color: Get.isDarkMode ? Colors.red : Colors.blue
Any recommendation how to do that?
Thank you.