kherel / animated_theme_switcher

Flutter animated theme switcher
https://pub.dev/packages/animated_theme_switcher
MIT License
278 stars 28 forks source link

Can't use implicit animations when having ThemeSwitchingArea #60

Closed chaosLegacy closed 1 year ago

chaosLegacy commented 2 years ago

I have a simple code where I animate a container

  @override
  Widget build(BuildContext context) {
    return ThemeSwitchingArea(
      child: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              AnimatedContainer(
                duration: const Duration(seconds: 2),
                color: _color,
                height: _height,
                width: _width,
                curve: Curves.bounceInOut,
                child: Image.asset('assets/images/coffee.png'),
              ),
              MaterialButton(
                onPressed: () => setState(() {
                  _color = _color == Colors.red ? Colors.deepPurple : Colors.red;
                  _height = _height == 100 ? 200 : 100;
                  _width = _width == 100 ? 300 : 100;
                }),
                child: const Icon(Icons.star),
              )
            ],
          ),
        ),
      ),
    );
  }

I noticed that with ThemeSwitchingArea, there's no animation at all, and it only works once I remove the widget

With ThemeSwitchingArea

https://user-images.githubusercontent.com/11313734/190719164-db604c65-c512-4774-a2b9-fd72a60086d1.mov

Without ThemeSwitchingArea

https://user-images.githubusercontent.com/11313734/190719241-04f90509-1968-496c-941f-56ab5963ad0e.mov

Any idea how to fix this issue :/

Ahmedibrahim66 commented 1 year ago

Did you find any workaround for this scenario?

kherel commented 1 year ago

Sorry I missed this, I'll take a look the next weekend

kherel commented 1 year ago

hopefully fixed in 2.0.8