2d-inc / Flare-Flutter

Load and get full control of your Rive files in a Flutter project using this library.
https://rive.app/
MIT License
2.55k stars 470 forks source link

Expand FlareActor to fill parent #273

Open doppio opened 3 years ago

doppio commented 3 years ago

Hello!

I'm trying to fit a FlareActor to its parent by width, which I can by providing a fit of BoxFit.contain and setting the sizeFromArtboard parameter to true. The size of the rendered art is correct, but the widget takes up much more vertical space than necessary. It seems like it should be possible for the FlareActor to size itself such that it fills up constraints as much as possible, while maintaining its native aspect ratio. Is this already supported?

luigi-rosso commented 3 years ago

Hey @doppio, yes you can do that! You'd want sizeFromArtboard to be false in this case and set fit to BoxFit.contain. That'll take up the full size of the parent and then scale down whichever side exceeds the boundaries based on the aspect. If you specifically want to fit the width, try setting fit to BoxFit.width instead, but note that the height may bleed if the aspect of the artboard is inverted from that of the container. Take a peek at https://api.flutter.dev/flutter/painting/BoxFit-class.html for more details.