mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-06-27 18:28:18 +08:00
Updates docs
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
## [0.7.18] - 2021-06-14 12:00:00
|
||||
- Adds ability to pass controllers into RiveAnimation widgets
|
||||
- Adds autoplay option to SimpleAnimation controller
|
||||
- Adds one-shot animation contoller
|
||||
- Updates examples
|
||||
|
||||
## [0.7.17] - 2021-06-11 18:00:00
|
||||
- Exposes antialiasing option in Rive and RiveAnimation widgets.
|
||||
|
57
README.md
57
README.md
@ -98,6 +98,63 @@ class _PlayPauseAnimationState extends State<PlayPauseAnimation> {
|
||||
}
|
||||
```
|
||||
|
||||
Play a one-shot animation repeatedly on demand
|
||||
|
||||
```dart
|
||||
/// Demonstrates playing a one-shot animation on demand
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
class PlayOneShotAnimation extends StatefulWidget {
|
||||
const PlayOneShotAnimation({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_PlayOneShotAnimationState createState() => _PlayOneShotAnimationState();
|
||||
}
|
||||
|
||||
class _PlayOneShotAnimationState extends State<PlayOneShotAnimation> {
|
||||
/// Controller for playback
|
||||
late RiveAnimationController _controller;
|
||||
|
||||
/// Is the animation currently playing?
|
||||
bool _isPlaying = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = OnShotAnimation(
|
||||
'bounce',
|
||||
autoplay: false,
|
||||
onStop: () => setState(() => _isPlaying = false),
|
||||
onStart: () => setState(() => _isPlaying = true),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('One-Shot Example'),
|
||||
),
|
||||
body: Center(
|
||||
child: RiveAnimation.network(
|
||||
'https://cdn.rive.app/animations/vehicles.riv',
|
||||
animations: const ['idle', 'curves'],
|
||||
controllers: [_controller],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
// disable the button while playing the animation
|
||||
onPressed: () => _isPlaying ? null : _controller.isActive = true,
|
||||
tooltip: 'Play',
|
||||
child: const Icon(Icons.arrow_upward),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Antialiasing
|
||||
|
||||
If you want to disable antialiasing (usually for performance reasons), you can set `antialiasing` to `false` on the `Rive` and `RiveAnimation` widgets.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/// Demonstrates play a one-shot animation on demand
|
||||
/// Demonstrates playing a one-shot animation on demand
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
@ -36,7 +36,7 @@ class _PlayOneShotAnimationState extends State<PlayOneShotAnimation> {
|
||||
),
|
||||
body: Center(
|
||||
child: RiveAnimation.network(
|
||||
'https://cdn.rive.app/vehicles.riv',
|
||||
'https://cdn.rive.app/animations/vehicles.riv',
|
||||
animations: const ['idle', 'curves'],
|
||||
controllers: [_controller],
|
||||
),
|
||||
|
Reference in New Issue
Block a user