flutter_confetti icon indicating copy to clipboard operation
flutter_confetti copied to clipboard

Confetti package animation not displaying correctly upon scroll

Open Aristidios opened this issue 2 years ago • 5 comments

I'm using Package Confetti 0.6.0 ConfettiWidget() within Card()s generated in a GridView.builder

Upon scroll the animation stops working properly & even vanishes if I scroll too much.

SliverGrid with Confetti Animation

I thought the issue had to do with lazy loading, so I tried two other particle animation widgets:

  1. Particles 0.1.4 and
  2. Animated Background 2.0.0

Both of which worked fine, displaying correct animation - even through scrolling.

-> It could be just an issue with Package Confetti 0.6.0, but I think the problem might come from the way I'm initializing the ConfettiController and calling .play() method & disposing of it.

Here is my complete simplified code:

class HomePage extends StatefulWidget {
  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  late ConfettiController _controllerCenter;

  @override
  void initState() {
    super.initState();
    _controllerCenter =
        ConfettiController(duration: const Duration(seconds: 1000));
    _controllerCenter.play();
  }

  @override
  void dispose() {
    _controllerCenter.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: SafeArea(
        child: new GridView.builder(
          itemCount: 30,
          itemBuilder: (BuildContext context, int index) {
            return Card(
              child: Center(
// 
                child: ConfettiWidget(
                  confettiController: _controllerCenter,
                  shouldLoop: true,
                ),
//
              ),
            );
          },
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
          ),
        ),
      ),
    );
  }
}

-> I'd like to keep the animation running despite scrolling through the GridView.

I need to use a GridView.builder or GridView.count as data within the cards will be populated with Firebase Data.

Aristidios avatar Nov 22 '21 11:11 Aristidios

Any update on this? Facing similar issue.

Bhat015 avatar Dec 24 '21 01:12 Bhat015

Same for me..

roubachof avatar Apr 02 '22 17:04 roubachof

same issue any update??

jaskiratAtNexG avatar May 17 '22 13:05 jaskiratAtNexG

I'm facing similar issues. It looks like theres some problem when the size of the confetti area is calculated.

Eerey avatar Sep 02 '22 15:09 Eerey

@Eerey canvas: const Size(double.infinity, double.infinity), use canvas like this and this issue will resolve. canvas property of Confetti widget

jaskiratAtNexG avatar Sep 02 '22 15:09 jaskiratAtNexG