getx
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.
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
Please, use context.theme.
Get.theme should not be used inside widgets.
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).
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)