How to change Text color with Get in Flutter

Viewed 37

How can i change my Texts color immedietly

TextStyle get headingStyle {

  return GoogleFonts.lato(
      textStyle: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
      color:Get.isDarkMode?Colors.white:Colors.black);
}

color changes when i hot reloud but doesn't change when i clicked the button(button changes isDarkMode )

1 Answers

Try put the Obx. It's create an observable in your code

TextStyle get headingStyle {

  return Obx(() => GoogleFonts.lato(
      textStyle: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
      color:Get.isDarkMode?Colors.white:Colors.black));
}
Related