mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-11-09 01:16:42 +08:00
Flutter release 0.13.5
Tested out the latest rive-common that now uses `package:web` and `dart:js_interop` The `RiveFile.initializeText` and everything associated with it are deprecated. Instead, use `RiveFile.initialize`, which will always need to be called when initializing text, audio, and layout. Calling it `initializeText` is confusing to users as they may not be using text, but still need to call this manually when using RiveFile.import. There is maybe additional cleanup we could do here, but at least want to make sure the public API is not confusing. Diffs= fa7c55934 Flutter release 0.13.5 (#7305) 973ff2276 Fix warnings about invalid toolsets (#7300) Co-authored-by: Gordon <pggordonhayes@gmail.com>
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
/// An example showing how to drive a StateMachine via a trigger input.
|
||||
@ -11,42 +10,34 @@ class LittleMachine extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LittleMachineState extends State<LittleMachine> {
|
||||
/// Tracks if the animation is playing by whether controller is running.
|
||||
bool get isPlaying => _controller?.isActive ?? false;
|
||||
|
||||
/// Message that displays when state has changed
|
||||
String stateChangeMessage = '';
|
||||
|
||||
Artboard? _riveArtboard;
|
||||
StateMachineController? _controller;
|
||||
SMITrigger? _trigger;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadRiveFile();
|
||||
}
|
||||
|
||||
// Load the animation file from the bundle, note that you could also
|
||||
// download this. The RiveFile just expects a list of bytes.
|
||||
rootBundle.load('assets/little_machine.riv').then(
|
||||
(data) async {
|
||||
// Load the RiveFile from the binary data.
|
||||
final file = RiveFile.import(data);
|
||||
Future<void> _loadRiveFile() async {
|
||||
final file = await RiveFile.asset('assets/little_machine.riv');
|
||||
|
||||
// The artboard is the root of the animation and gets drawn in the
|
||||
// Rive widget.
|
||||
final artboard = file.mainArtboard;
|
||||
var controller = StateMachineController.fromArtboard(
|
||||
artboard,
|
||||
'State Machine 1',
|
||||
onStateChange: _onStateChange,
|
||||
);
|
||||
if (controller != null) {
|
||||
artboard.addController(controller);
|
||||
_trigger = controller.getTriggerInput('Trigger 1');
|
||||
}
|
||||
setState(() => _riveArtboard = artboard);
|
||||
},
|
||||
// The artboard is the root of the animation and gets drawn in the
|
||||
// Rive widget.
|
||||
final artboard = file.mainArtboard;
|
||||
var controller = StateMachineController.fromArtboard(
|
||||
artboard,
|
||||
'State Machine 1',
|
||||
onStateChange: _onStateChange,
|
||||
);
|
||||
if (controller != null) {
|
||||
artboard.addController(controller);
|
||||
_trigger = controller.getTriggerInput('Trigger 1');
|
||||
}
|
||||
setState(() => _riveArtboard = artboard);
|
||||
}
|
||||
|
||||
/// Do something when the state machine changes state
|
||||
|
||||
Reference in New Issue
Block a user