Making a responsive button with the new Stack layout (Duolingo button, part 3)
I rebuilt the Duolingo button from my earlier tutorials as a responsive component, using the new Stack layout, and then used it in a real Flutter app.
How it's built:
1. The Artboard is exactly the button (240x44), with its layout set to Stack, aligned center.
2. No groups, since groups can't be Layout children. The face and the label are wrapped in a Layout, and the default Column is changed to Stack, so the label sits on the face without Absolute positioning.
3. The face Stack and its Shape Layout are both set to Fill, so they follow whatever size the runtime gives the Artboard.
4. The 3D depth comes from margins: 4px at the bottom of the face, 4px at the top of the base.
5. The press animates those margins instead of the position, so it works at any button size.
6. A "pressed" Trigger on the View Model fires once per press (unlike isPressed), and the app listens to it.
In the app: Flutter with Fit.layout, one View Model instance per button. Two buttons from the same Artboard drive a separate .riv with the avatar and the weather.
Video + free starter file: https://youtu.be/EiwtZH1caIY
Written version with the Flutter code: https://www.rivemasterclass.com/blog/rive-layouts-responsive-button
And if you want to learn layouts in dept, I teach them in my Rive Masterclass
Hope you’ll find it helpful :)