funwithflutter / flutter_confetti

A Flutter widget that shoots confetti all over the screen.
https://pub.dev/packages/confetti
MIT License
439 stars 79 forks source link

Alignment does not work #71

Open Eerey opened 2 years ago

Eerey commented 2 years ago

I tried to wrap it around Align-Widgets - the children, the parent, everything. It never works consistently. I also tried to put the ConfettiWidget in a Stack with a fixed size (Container wrapped around it) -> It does not align correctly. Sometimes the ConfettiWidget only emits from a singular point and every single confetti is displayed in its untransformed (and untranslated) form. Is there some tricky behaviour underlying?

HayesGordon commented 2 years ago

Hi! Can you share some example code, or explain better what you're trying to do? The main example demonstrates different alignments

mirkancal commented 2 years ago

I'm also having the same issue; I've simply copied from the example but not sure what's missing. Confettis are shooting from a single point but can't move around the screen.

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Align(
          alignment: Alignment.center,
          child: ConfettiWidget(
            confettiController: _confettiController,
            shouldLoop:
                true, // start again as soon as the animation is finished
            colors: const [
              Colors.green,
              Colors.blue,
              Colors.pink,
              Colors.orange,
              Colors.purple
            ], // manually specify the colors to be used
          ),
        ),
image
Steellow commented 1 year ago

Also having the same problem. All confettis are stuck in place.

edit: Center seems to be working better. Or if you want to align it to some edge, aligning it with column and/or row seems to be working.

e2: Align seems to be working fine if you just set canvas: Size.infinite to ConfettiWidget.

TalebRafiepour commented 1 year ago

Also having the same problem. All confettis are stuck in place.

edit: Center seems to be working better. Or if you want to align it to some edge, aligning it with column and/or row seems to be working.

e2: Align seems to be working fine if you just set canvas: Size.infinite to ConfettiWidget.

When I set the canvas: Size.infinite some exceptions happened

[log] Matrix4 entries must be finite.
'dart:ui/painting.dart':
      Failed assertion: line 46 pos 10: '<optimized out>'

[log] #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      _matrix4IsValid (dart:ui/painting.dart:46:10)
#3      Path.transform (dart:ui/painting.dart:2738:12)
#4      ParticlePainter._paintParticles
confetti.dart:382
#5      ParticlePainter.paint
confetti.dart:359
#6      RenderCustomPaint._paintWithPainter
custom_paint.dart:571
#7      RenderCustomPaint.paint
custom_paint.dart:618
#8      RenderObject._paintWithContext
object.dart:2853
#9      PaintingContext.paintChild
object.dart:253
#10     RenderProxyBoxMixin.paint
proxy_box.dart:144
#11     RenderObject._paintWithContext
object.dart:2853
#12     PaintingContext._repaintCompositedChild
object.dart:169
#13     PaintingContext.repaintCompositedChild
object.dart:112
#14     PipelineOwner.flushPaint
object.dart:1137
#15     RendererBinding.drawFrame
binding.dart:518
#16     WidgetsBinding.drawFrame
binding.dart:865
#17     RendererBinding._handlePersistentFrameCallback
binding.dart:381
#18     SchedulerBinding._invokeFrameCallback
binding.dart:1289
#19     SchedulerBinding.handleDrawFrame
binding.dart:1218
#20     SchedulerBinding._handleDrawFrame
binding.dart:1076
#21     _rootRun (dart:async/zone.dart:1398:13)
#22     _CustomZone.run (dart:async/zone.dart:1300:19)
#23     _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
#24     _invoke (dart:ui/hooks.dart:147:10)
#25     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:338:5)
#26     _drawFrame (dart:ui/hooks.dart:112:31)  
Screenshot 2023-03-30 at 7 10 22 PM

‍‍‍