mjtalbot 236ae26640 Speed 4793
adds speed on states!

currently just to animation states 👇
<img width="1121" alt="image" src="https://user-images.githubusercontent.com/1216025/217915050-0bea976f-88b1-4aef-aeb0-bed6f36cc577.png">

I've called this 'AdvanceableState', which we could make blendstates/etc inherit from to give em the powers... not sure if there's a better name people can come up with here... also not sure if that empty lookin' class is the right way to do it, so i'd love feedback on that (and if there's a different example somewhere that would be super helpful to see as well)

also fixed up the generator scripts for dart 3, at least the dart ones, the cpp ones were beyond my patience, gotta dart 2.12 for those...

also fixed an issue where we were checking speed against playing backwards, not speed and direction!

@alxgibsn going to bug you for some styling input

works in both editor and viewer!

going to look about adding a test.. or two....

https://user-images.githubusercontent.com/1216025/217915843-6126d3cf-bf19-4a9d-9a95-adb3a498e75d.mov

https://user-images.githubusercontent.com/1216025/217915852-252d4f78-280e-4a63-838c-39d6b27e3e31.mov

Diffs=
ffeb9afaf Speed 4793 (#4806)
2023-02-16 10:29:00 +00:00
2022-11-19 20:19:05 +00:00
2023-02-15 23:47:35 +00:00
2023-02-16 10:29:00 +00:00
2022-11-15 23:07:11 +00:00
2023-02-15 23:47:35 +00:00
2022-11-15 23:07:11 +00:00
2022-11-15 23:07:11 +00:00
2022-11-15 23:07:11 +00:00
2023-02-16 10:29:00 +00:00
2023-02-15 23:47:35 +00:00
2023-02-15 23:47:35 +00:00
2020-07-08 16:36:55 -07:00
2022-11-15 23:07:11 +00:00
2022-11-15 23:07:11 +00:00
2023-02-15 23:47:35 +00:00
2023-01-11 21:04:30 +00:00
2022-11-15 23:07:11 +00:00
2022-06-16 15:51:45 -07:00

Pub Version Build Status Discord badge Twitter handle

Rive Flutter

Rive hero image

Rive Flutter is a runtime library for Rive, a real-time interactive design and animation tool.

This library allows you to fully control Rive files with a high-level API for simple interactions and animations, as well as a low-level API for creating custom render loops for multiple artboards, animations, and state machines in a single canvas.

Table of contents

Overview of Rive

Rive is a powerful tool that helps teams create and run interactive animations for apps, games, and websites. Designers and developers can use the collaborative editor to create motion graphics that respond to different states and user inputs, and then use the lightweight open-source runtime libraries, like Rive Flutter, to load their animations into their projects.

For more information, check out the following resources:

🏡 Homepage

📘 General help docs

🛠 Learning Rive

Getting Started

To get started with Rive Flutter, check out the following resources:

For additional help, see the Runtime sections of the Rive help documentation, such as:

Supported Platforms

Be sure to read the platform specific considerations for the Rive Flutter package.

Examples

To see some examples of what you can do with Rive Flutter, check out the following projects:

Here is an example of how to play an animation from a Rive file retrieved over HTTP:

import 'package:flutter/material.dart';
import 'package:rive/rive.dart';

void main() {
  runApp(MaterialApp(home: SimpleAnimation()));
}

class SimpleAnimation extends StatelessWidget {
  const SimpleAnimation({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Center(
        child: RiveAnimation.network(
          'https://cdn.rive.app/animations/vehicles.riv',
        ),
      ),
    );
  }
}

To play an animation from an asset bundle, use:

RiveAnimation.asset('assets/truck.riv');

Control playing and pausing a looping animation:

import 'package:flutter/material.dart';
import 'package:rive/rive.dart';

void main() {
  runApp(MaterialApp(home: PlayPauseAnimation()));
}

class PlayPauseAnimation extends StatefulWidget {
  const PlayPauseAnimation({Key? key}) : super(key: key);

  @override
  _PlayPauseAnimationState createState() => _PlayPauseAnimationState();
}

class _PlayPauseAnimationState extends State<PlayPauseAnimation> {
  // Controller for playback
  late RiveAnimationController _controller;

  // Toggles between play and pause animation states
  void _togglePlay() =>
      setState(() => _controller.isActive = !_controller.isActive);

  /// Tracks if the animation is playing by whether controller is running
  bool get isPlaying => _controller.isActive;

  @override
  void initState() {
    super.initState();
    _controller = SimpleAnimation('idle');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RiveAnimation.network(
          'https://cdn.rive.app/animations/vehicles.riv',
          controllers: [_controller],
          // Update the play state when the widget's initialized
          onInit: (_) => setState(() {}),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _togglePlay,
        tooltip: isPlaying ? 'Pause' : 'Play',
        child: Icon(
          isPlaying ? Icons.pause : Icons.play_arrow,
        ),
      ),
    );
  }
}

Play a one-shot animation repeatedly on demand

/// Demonstrates playing a one-shot animation on demand

import 'package:flutter/material.dart';
import 'package:rive/rive.dart';

void main() {
  runApp(MaterialApp(home: PlayOneShotAnimation()));
}

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 = OneShotAnimation(
      '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),
      ),
    );
  }
}

Contributing

We love contributions and all are welcome! 💙

Issues

Have an issue with using the runtime, or want to suggest a feature/API to help make your development life better? Log an issue in our issues tab! You can also browse older issues and discussion threads there to see solutions that may have worked for common problems.

Description
Flutter runtime for Rive
Readme MIT 8.9 MiB
Languages
Dart 96.8%
C++ 1.3%
Lua 0.7%
CMake 0.6%
Shell 0.2%
Other 0.2%