rive-flutter
rive-flutter copied to clipboard
Are additive animations supported in rive flutter ?
Are additive animations supported in rive flutter ?
Hello I have been trying to use the additve animation but its being skipped in my time machine, below you will find the context.
code:
import 'package:flutter/material.dart';
import 'package:rive/rive.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
SMITrigger? fail;
SMITrigger? success;
void _onRiveInit(Artboard artboard) {
final controller = StateMachineController.fromArtboard(
artboard, 'login machine',
onStateChange: _onStateChange);
artboard.addController(controller!);
fail = controller.findInput<bool>('fail') as SMITrigger;
success = controller.findInput<bool>('success') as SMITrigger;
}
void _onStateChange(
String stateMachineName,
String stateName,
) =>
setState(
() => 'State Changed in $stateMachineName to $stateName',
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Simple Animation'),
),
body: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FloatingActionButton(onPressed: () => fail!.fire()),
FloatingActionButton(onPressed: () => success!.fire(), backgroundColor: Colors.blue),
],
),
SizedBox(
height: 200,
width: 200,
child: Center(
child: RiveAnimation.asset(
'assets/daftar.riv',
fit: BoxFit.fitHeight,
stateMachines: ['login machine'],
onInit: _onRiveInit,
),
),
),
]),
);
}
}
pubspec.yaml
environment:
sdk: '>=3.0.0'
dependencies:
flutter:
sdk: flutter
go_router: ^7.0.0
hive: ^2.2.3
hive_flutter: ^1.1.0
flutter_secure_storage: ^8.0.0
cupertino_icons: ^1.0.2
http: ^0.13.6
rive: ^0.11.3
dev_dependencies:
flutter_test:
sdk: flutter
hive_generator: ^2.0.0
build_runner: ^2.4.2
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
assets:
- assets/
rive backup and riv files will be attached.
please notice the last blend state where its additive its just being skipped in the flutter runtime
Hi @FuadFox additive animations are supported, but it seems like you found a bug/inconsistency between the runtime and the editor. We'll take a look into this, thanks for opening the issue.
In the meantime, I noticed that if you add an additional timeline to the additive blend then it will work. Or alternatively for your animation it seems like you do not need a blend state at all if you're only using one timeline at 100. You could use a normal animation instead of the blend.
Closing this as it should be resolved in the latest version. If not please feel free to reopen. Also note that a likely reason for the above issues was that the same State Machine Controller was added twice. In the widget constructor and manually using addController