getx icon indicating copy to clipboard operation
getx copied to clipboard

After Get.changeTheme(), My Widget reference my themeData.xxxColor, Get.theme.xxxColor won't change, but Theme.of(context).theme.xxxColor will change.

Open junixapp opened this issue 2 years ago • 3 comments

Describe the bug After Get.changeTheme(), My Widget reference my themeData.xxxColor, Get.theme.xxxColor won't change, but Theme.of(context).theme.xxxColor will change, but I have to pass through context.

Is there a better solution?

example:


class Home extends StatelessWidget {
  @override
  Widget build(context) => Scaffold(
      appBar: AppBar(title: Text("Test Change Theme")),
      body: Center(
        child: Text("$count", style: TextStyle(color: Get.theme.xxxColor))
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () => Get.changeTheme(),
      ));
}

Flutter Version: 3.7.5

Getx Version: 4.6.5

Describe on which device you found the bug: HuaWei Mate20

junixapp avatar Feb 25 '23 03:02 junixapp

Please, use context.theme.

Get.theme should not be used inside widgets.

jonataslaw avatar Feb 25 '23 14:02 jonataslaw

Please, use context.theme.

Get.theme should not be used inside widgets.

I insist that you put it in the docs, i almost lost my mind trying to figure out why my theme changes partially and had to succumb to the darkest side of the development - await Future.delayed(const Duration(milliseconds: 600));😄

Using the context i still had to call Get.forceAppUpdate(); manually to invoke the change animation. Please, add this info to the doc (i used this one).

princer007-GoS avatar Mar 23 '23 20:03 princer007-GoS

Please, use context.theme.

Get.theme should not be used inside widgets.

Can you collaborate on it please?

We use a lot such approach as you suggest should not be used, like: Get.theme.canvasColor.withOpacity(0.7)

alexandr-efimov avatar Dec 14 '23 21:12 alexandr-efimov