How to expand Rive animation in Flutter?

349

Just adding height and width to his parent Container and add a fit(cover, fill, whatever you need) to your Rive widget

 Container(
           width: w,
           height: h,
           child: Rive(
               fit: BoxFit.cover,
               artboard: ctrl.globalArtboard!,
          ),
    ),
Share:
349
helloitsme3
Author by

helloitsme3

Updated on December 01, 2022

Comments

  • helloitsme3
    helloitsme3 over 1 year

    I want to make rive animation background and feel whole screen. Changing height and width to MediaQuery... does not work. It changes size but proportion stays the same

    This is how rive widget looks like for me:

    Center(
                child: _riveArtboard == null
                    ? const SizedBox()
                    : Rive(artboard: _riveArtboard),
              ),
    

    thank you in advance

    edit: SOLUTION

    Container(
              height: h,
              width: w,
              child: Center(
                child: _riveArtboard == null
                    ? const SizedBox()
                    : Rive(fit: BoxFit.fill, artboard: _riveArtboard),
              ),
            ),
    
    • Yeasin Sheikh
      Yeasin Sheikh over 2 years
      Have you got the solution?
    • helloitsme3
      helloitsme3 over 2 years
      yes, after a few tries and posting quests, I got it
    • Ibrahim Yildirim
      Ibrahim Yildirim over 2 years
      @helloitsme3 can you please post your answer on the thread? You can mark your own answers as accepted and help other people with this issue :)
    • helloitsme3
      helloitsme3 over 2 years
      @IbrahimYildirim I edited question, there is solution in description :)