I’d like to make an external dart file (let’s call it color_palette.dart), that have some classes of colors. These classes would be able to be changed by a menu on another page of the app. These colors would be used in all the pages to define the colors of Appbar, buttons, icons, etc…
I don’t want to use the theme() for it.
I want to use some functions that can be used in a button (onPress : function) to change the colors.
Here is an example :
color_palette.dart
class myColor {
return Colors.red;
}
mainpage.dart
Scaffold(
appbar : AppBar(
color : MyColor(),
)
)
2
Answers
There are many ways to do that:
First method:
The second method, Using a color class.
very easy to do