-
Notifications
You must be signed in to change notification settings - Fork 222
Description
I'm trying to run my Rive (.riv) project in Flutter, but the exit animation is inconsistent with the one created in Rive
https://rive.app/community/files/17975-33729-dish/
In Flutter:
document_5084644436923649443.mp4
code: import 'package:flutter/material.dart';
import 'package:rive/rive.dart' hide LinearGradient;
class DishScreen extends StatefulWidget {
const DishScreen({super.key});
@OverRide
State createState() => _DishScreenState();
}
class _DishScreenState extends State {
Artboard? _riveArtboard;
Future _loadRiveFile() async {
final riveFile = await RiveFile.asset('assets/untitled.riv');
final artboard = riveFile.mainArtboard.instance();
var controller = StateMachineController.fromArtboard(artboard, 'dish');
if (controller != null) {
artboard.addController(controller);
setState(() {
_riveArtboard = artboard;
});
}
}
@OverRide
void initState() {
Future.microtask(
() async => await _loadRiveFile(),
);
super.initState();
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: _riveArtboard != null
? Rive(artboard: _riveArtboard!)
: SizedBox(
height: 100,
),
);
}
}