-1

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 Answers1

0

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));
}
Sergio Clemente
  • 809
  • 8
  • 12
  • I'm returning TextStyle how can i return Obx I call this function for my text's style 'Text("example" style:headingStyle)' And GoogleFonts is not a Widget i could not understand how can i use Obx. – SpookySkeleton Sep 11 '22 at 19:24
  • U need put the Obx in someplace. And put and update(); too. But the Obx only Works n directlly getx obs variable – Sergio Clemente Sep 11 '22 at 21:49