Working on nnbd.

This commit is contained in:
Luigi Rosso
2021-03-22 14:49:42 -07:00
parent 462faf20ff
commit 33ad1c9ac8
137 changed files with 1157 additions and 1141 deletions

View File

@ -28,18 +28,16 @@ class _ExampleAnimationState extends State<ExampleAnimation> {
// download this. The RiveFile just expects a list of bytes.
rootBundle.load('assets/dino.riv').then(
(data) async {
final file = RiveFile();
// Load the RiveFile from the binary data.
if (file.import(data)) {
// The artboard is the root of the animation and gets drawn in the
// Rive widget.
final artboard = file.mainArtboard;
// Add a controller to play back a known animation on the main/default
// artboard. We store a reference to it so we can toggle playback.
artboard.addController(_controller = SimpleAnimation('Run'));
setState(() => _riveArtboard = artboard);
}
final file = RiveFile.import(data);
// The artboard is the root of the animation and gets drawn in the
// Rive widget.
final artboard = file.mainArtboard;
// Add a controller to play back a known animation on the main/default
// artboard. We store a reference to it so we can toggle playback.
artboard.addController(_controller = SimpleAnimation('Run'));
setState(() => _riveArtboard = artboard);
},
);
}

View File

@ -11,10 +11,6 @@ class ExampleStateMachine extends StatefulWidget {
}
class _ExampleStateMachineState extends State<ExampleStateMachine> {
void _togglePlay() {
setState(() => _controller.isActive = !_controller.isActive);
}
/// Tracks if the animation is playing by whether controller is running.
bool get isPlaying => _controller?.isActive ?? false;
@ -31,22 +27,20 @@ class _ExampleStateMachineState extends State<ExampleStateMachine> {
// download this. The RiveFile just expects a list of bytes.
rootBundle.load('assets/rocket.riv').then(
(data) async {
final file = RiveFile();
// Load the RiveFile from the binary data.
if (file.import(data)) {
// The artboard is the root of the animation and gets drawn in the
// Rive widget.
final artboard = file.mainArtboard;
var controller =
StateMachineController.fromArtboard(artboard, 'Button');
if (controller != null) {
artboard.addController(controller);
_hoverInput = controller.findInput('Hover');
_pressInput = controller.findInput('Press');
}
setState(() => _riveArtboard = artboard);
final file = RiveFile.import(data);
// The artboard is the root of the animation and gets drawn in the
// Rive widget.
final artboard = file.mainArtboard;
var controller =
StateMachineController.fromArtboard(artboard, 'Button');
if (controller != null) {
artboard.addController(controller);
_hoverInput = controller.findInput('Hover');
_pressInput = controller.findInput('Press');
}
setState(() => _riveArtboard = artboard);
},
);
}