├── VERSION
├── example
├── ios
│ ├── Flutter
│ │ ├── Debug.xcconfig
│ │ ├── Release.xcconfig
│ │ └── AppFrameworkInfo.plist
│ ├── Runner
│ │ ├── Runner-Bridging-Header.h
│ │ ├── Assets.xcassets
│ │ │ ├── LaunchImage.imageset
│ │ │ │ ├── LaunchImage.png
│ │ │ │ ├── LaunchImage@2x.png
│ │ │ │ ├── LaunchImage@3x.png
│ │ │ │ ├── README.md
│ │ │ │ └── Contents.json
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── Icon-App-20x20@1x.png
│ │ │ │ ├── Icon-App-20x20@2x.png
│ │ │ │ ├── Icon-App-20x20@3x.png
│ │ │ │ ├── Icon-App-29x29@1x.png
│ │ │ │ ├── Icon-App-29x29@2x.png
│ │ │ │ ├── Icon-App-29x29@3x.png
│ │ │ │ ├── Icon-App-40x40@1x.png
│ │ │ │ ├── Icon-App-40x40@2x.png
│ │ │ │ ├── Icon-App-40x40@3x.png
│ │ │ │ ├── Icon-App-60x60@2x.png
│ │ │ │ ├── Icon-App-60x60@3x.png
│ │ │ │ ├── Icon-App-76x76@1x.png
│ │ │ │ ├── Icon-App-76x76@2x.png
│ │ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── AppDelegate.swift
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ └── IDEWorkspaceChecks.plist
│ ├── Runner.xcodeproj
│ │ └── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ └── IDEWorkspaceChecks.plist
│ └── .gitignore
├── macos
│ ├── Flutter
│ │ ├── Flutter-Debug.xcconfig
│ │ ├── Flutter-Release.xcconfig
│ │ └── GeneratedPluginRegistrant.swift
│ ├── Runner
│ │ ├── Configs
│ │ │ ├── Debug.xcconfig
│ │ │ ├── Release.xcconfig
│ │ │ ├── Warnings.xcconfig
│ │ │ └── AppInfo.xcconfig
│ │ ├── Assets.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── app_icon_128.png
│ │ │ │ ├── app_icon_16.png
│ │ │ │ ├── app_icon_256.png
│ │ │ │ ├── app_icon_32.png
│ │ │ │ ├── app_icon_512.png
│ │ │ │ ├── app_icon_64.png
│ │ │ │ ├── app_icon_1024.png
│ │ │ │ └── Contents.json
│ │ ├── AppDelegate.swift
│ │ ├── Release.entitlements
│ │ ├── MainFlutterWindow.swift
│ │ ├── DebugProfile.entitlements
│ │ └── Info.plist
│ ├── .gitignore
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── Runner.xcodeproj
│ │ └── project.xcworkspace
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
├── web
│ ├── favicon.png
│ ├── icons
│ │ ├── Icon-192.png
│ │ └── Icon-512.png
│ ├── manifest.json
│ └── index.html
├── assets
│ ├── rocket.riv
│ ├── skills.riv
│ ├── teeny_tiny.riv
│ ├── off_road_car.riv
│ ├── liquid_download.riv
│ └── little_machine.riv
├── android
│ ├── gradle.properties
│ ├── .gitignore
│ ├── app
│ │ └── src
│ │ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── drawable
│ │ │ │ │ └── launch_background.xml
│ │ │ │ └── values
│ │ │ │ │ └── styles.xml
│ │ │ └── kotlin
│ │ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── rive_example
│ │ │ │ └── MainActivity.kt
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ ├── settings.gradle
│ └── build.gradle
├── .metadata
├── pubspec.yaml
├── README.md
├── lib
│ ├── simple_animation.dart
│ ├── simple_state_machine.dart
│ └── custom_controller.dart
└── .gitignore
├── lib
├── src
│ ├── rive_core
│ │ ├── transform_space.dart
│ │ ├── shapes
│ │ │ ├── paint
│ │ │ │ ├── stroke_effect.dart
│ │ │ │ ├── radial_gradient.dart
│ │ │ │ ├── gradient_stop.dart
│ │ │ │ ├── shape_paint_mutator.dart
│ │ │ │ └── fill.dart
│ │ │ ├── contour_mesh_vertex.dart
│ │ │ ├── path_vertex.dart
│ │ │ ├── mesh_vertex.dart
│ │ │ ├── triangle.dart
│ │ │ ├── cubic_vertex.dart
│ │ │ ├── polygon.dart
│ │ │ ├── straight_vertex.dart
│ │ │ └── star.dart
│ │ ├── assets
│ │ │ ├── folder.dart
│ │ │ ├── asset.dart
│ │ │ ├── drawable_asset.dart
│ │ │ ├── file_asset_contents.dart
│ │ │ └── image_asset.dart
│ │ ├── animation
│ │ │ ├── interpolator.dart
│ │ │ ├── blend_animation_1d.dart
│ │ │ ├── state_machine_number.dart
│ │ │ ├── state_machine_trigger.dart
│ │ │ ├── any_state.dart
│ │ │ ├── exit_state.dart
│ │ │ ├── entry_state.dart
│ │ │ ├── state_machine_bool.dart
│ │ │ ├── loop.dart
│ │ │ ├── keyframe_interpolation.dart
│ │ │ ├── event_trigger_change.dart
│ │ │ ├── blend_state_direct.dart
│ │ │ ├── nested_state_machine.dart
│ │ │ ├── state_machine_layer_component.dart
│ │ │ ├── transition_value_condition.dart
│ │ │ ├── event_number_change.dart
│ │ │ ├── keyframe_id.dart
│ │ │ ├── blend_state.dart
│ │ │ ├── transition_trigger_condition.dart
│ │ │ ├── state_machine_input.dart
│ │ │ ├── keyframe_bool.dart
│ │ │ ├── nested_remap_animation.dart
│ │ │ ├── animation.dart
│ │ │ ├── event_bool_change.dart
│ │ │ ├── transition_bool_condition.dart
│ │ │ ├── animation_state_instance.dart
│ │ │ ├── nested_simple_animation.dart
│ │ │ ├── blend_state_direct_instance.dart
│ │ │ ├── blend_animation_direct.dart
│ │ │ ├── state_machine.dart
│ │ │ ├── state_instance.dart
│ │ │ ├── keyframe_double.dart
│ │ │ ├── blend_state_transition.dart
│ │ │ ├── keyframe_color.dart
│ │ │ ├── layer_state.dart
│ │ │ └── transition_number_condition.dart
│ │ ├── bones
│ │ │ ├── skeletal_component.dart
│ │ │ ├── root_bone.dart
│ │ │ ├── cubic_weight.dart
│ │ │ └── skinnable.dart
│ │ ├── math
│ │ │ ├── circle_constant.dart
│ │ │ └── path_types.dart
│ │ ├── event.dart
│ │ ├── runtime
│ │ │ └── exceptions
│ │ │ │ ├── rive_format_error_exception.dart
│ │ │ │ └── rive_unsupported_version_exception.dart
│ │ ├── state_transition_flags.dart
│ │ ├── node.dart
│ │ ├── nested_animation.dart
│ │ ├── backboard.dart
│ │ ├── constraints
│ │ │ ├── transform_component_constraint_y.dart
│ │ │ ├── transform_space_constraint.dart
│ │ │ ├── targeted_constraint.dart
│ │ │ └── transform_component_constraint.dart
│ │ ├── rive_animation_controller.dart
│ │ ├── world_transform_component.dart
│ │ ├── draw_target.dart
│ │ └── draw_rules.dart
│ ├── local_file_io.dart
│ ├── utilities
│ │ ├── utilities.dart
│ │ └── tops.dart
│ ├── core
│ │ ├── field_types
│ │ │ ├── core_field_type.dart
│ │ │ ├── core_int_type.dart
│ │ │ ├── core_bool_type.dart
│ │ │ ├── core_color_type.dart
│ │ │ ├── core_uint_type.dart
│ │ │ ├── core_double_type.dart
│ │ │ ├── core_string_type.dart
│ │ │ └── core_bytes_type.dart
│ │ └── importers
│ │ │ ├── artboard_import_stack_object.dart
│ │ │ ├── linear_animation_importer.dart
│ │ │ ├── state_machine_importer.dart
│ │ │ ├── keyed_object_importer.dart
│ │ │ ├── state_machine_event_importer.dart
│ │ │ ├── keyed_property_importer.dart
│ │ │ ├── state_transition_importer.dart
│ │ │ ├── file_asset_importer.dart
│ │ │ ├── artboard_importer.dart
│ │ │ ├── state_machine_layer_importer.dart
│ │ │ └── layer_state_importer.dart
│ ├── local_file_web.dart
│ ├── generated
│ │ ├── asset_base.dart
│ │ ├── backboard_base.dart
│ │ ├── assets
│ │ │ ├── folder_base.dart
│ │ │ ├── image_asset_base.dart
│ │ │ ├── asset_base.dart
│ │ │ ├── file_asset_base.dart
│ │ │ └── file_asset_contents_base.dart
│ │ ├── shapes
│ │ │ ├── path_composer_base.dart
│ │ │ ├── paint
│ │ │ │ ├── radial_gradient_base.dart
│ │ │ │ ├── solid_color_base.dart
│ │ │ │ ├── fill_base.dart
│ │ │ │ └── shape_paint_base.dart
│ │ │ ├── path_vertex_base.dart
│ │ │ ├── contour_mesh_vertex_base.dart
│ │ │ ├── cubic_vertex_base.dart
│ │ │ ├── shape_base.dart
│ │ │ ├── ellipse_base.dart
│ │ │ └── triangle_base.dart
│ │ ├── animation
│ │ │ ├── state_machine_base.dart
│ │ │ ├── layer_state_base.dart
│ │ │ ├── state_machine_layer_component_base.dart
│ │ │ ├── event_trigger_change_base.dart
│ │ │ ├── state_machine_input_base.dart
│ │ │ ├── state_machine_layer_base.dart
│ │ │ ├── transition_trigger_condition_base.dart
│ │ │ ├── any_state_base.dart
│ │ │ ├── exit_state_base.dart
│ │ │ ├── blend_state_base.dart
│ │ │ ├── entry_state_base.dart
│ │ │ ├── state_machine_trigger_base.dart
│ │ │ ├── nested_state_machine_base.dart
│ │ │ ├── transition_bool_condition_base.dart
│ │ │ ├── blend_state_direct_base.dart
│ │ │ ├── animation_base.dart
│ │ │ ├── keyframe_id_base.dart
│ │ │ ├── keyframe_color_base.dart
│ │ │ ├── keyframe_bool_base.dart
│ │ │ ├── keyframe_double_base.dart
│ │ │ ├── keyed_object_base.dart
│ │ │ ├── event_input_change_base.dart
│ │ │ ├── blend_animation_1d_base.dart
│ │ │ ├── transition_condition_base.dart
│ │ │ ├── state_machine_double_base.dart
│ │ │ ├── event_bool_change_base.dart
│ │ │ ├── blend_animation_base.dart
│ │ │ ├── keyed_property_base.dart
│ │ │ ├── event_number_change_base.dart
│ │ │ ├── state_machine_component_base.dart
│ │ │ ├── transition_double_condition_base.dart
│ │ │ ├── blend_animation_direct_base.dart
│ │ │ ├── transition_value_condition_base.dart
│ │ │ ├── state_machine_bool_base.dart
│ │ │ └── state_machine_number_base.dart
│ │ ├── container_component_base.dart
│ │ ├── bones
│ │ │ └── skeletal_component_base.dart
│ │ ├── constraints
│ │ │ ├── transform_constraint_base.dart
│ │ │ ├── rotation_constraint_base.dart
│ │ │ ├── scale_constraint_base.dart
│ │ │ ├── translation_constraint_base.dart
│ │ │ └── constraint_base.dart
│ │ └── nested_animation_base.dart
│ ├── blend_animations.dart
│ ├── asset_list.dart
│ ├── state_machine_components.dart
│ ├── container_children.dart
│ ├── state_transitions.dart
│ ├── input_changes.dart
│ ├── animation_list.dart
│ ├── state_transition_conditions.dart
│ ├── extensions.dart
│ └── controllers
│ │ └── one_shot_controller.dart
├── math.dart
├── components.dart
└── rive.dart
├── test
├── assets
│ └── rive-flutter-test-asset.riv
├── src
│ └── utils.dart
├── rive_file_test.dart
└── artboard_test.dart
├── .github
├── scripts
│ └── release
│ │ ├── release.sh
│ │ ├── package.json
│ │ ├── changelog.hbs
│ │ └── .release-it.json
└── workflows
│ ├── tests.yaml
│ └── publish.yaml
├── .metadata
├── pubspec.yaml
└── LICENSE
/VERSION:
--------------------------------------------------------------------------------
1 | 0.8.4
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/lib/src/rive_core/transform_space.dart:
--------------------------------------------------------------------------------
1 | enum TransformSpace { world, local }
2 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/web/favicon.png
--------------------------------------------------------------------------------
/example/assets/rocket.riv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/assets/rocket.riv
--------------------------------------------------------------------------------
/example/assets/skills.riv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/assets/skills.riv
--------------------------------------------------------------------------------
/example/assets/teeny_tiny.riv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/assets/teeny_tiny.riv
--------------------------------------------------------------------------------
/example/assets/off_road_car.riv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/assets/off_road_car.riv
--------------------------------------------------------------------------------
/example/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/example/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/example/assets/liquid_download.riv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/assets/liquid_download.riv
--------------------------------------------------------------------------------
/example/assets/little_machine.riv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/assets/little_machine.riv
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/lib/math.dart:
--------------------------------------------------------------------------------
1 | export 'package:rive/src/rive_core/math/mat2d.dart';
2 | export 'package:rive/src/rive_core/math/vec2d.dart';
3 |
--------------------------------------------------------------------------------
/example/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/xcuserdata/
7 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/test/assets/rive-flutter-test-asset.riv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/test/assets/rive-flutter-test-asset.riv
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/paint/stroke_effect.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | abstract class StrokeEffect {
4 | Path effectPath(Path source);
5 | void invalidateEffect();
6 | }
7 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/lib/components.dart:
--------------------------------------------------------------------------------
1 | export 'package:rive/src/rive_core/node.dart';
2 | export 'package:rive/src/rive_core/transform_component.dart';
3 | export 'package:rive/src/rive_core/world_transform_component.dart';
4 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/lib/src/rive_core/assets/folder.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/assets/folder_base.dart';
2 | export 'package:rive/src/generated/assets/folder_base.dart';
3 |
4 | class Folder extends FolderBase {}
5 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/X-SLAYER/rive-flutter/master/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/android/app/src/main/kotlin/com/example/rive_example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.rive_example
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lib/src/local_file_io.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 | import 'dart:typed_data';
3 |
4 | /// Load a list of bytes from a file on the local filesystem at [path].
5 | Future localFileBytes(String path) => File(path).readAsBytes();
6 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 |
9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
10 | }
11 |
--------------------------------------------------------------------------------
/lib/src/utilities/utilities.dart:
--------------------------------------------------------------------------------
1 | /// Szudzik's function for hashing two ints together
2 | int szudzik(int a, int b) {
3 | // a and b must be >= 0
4 | int x = a.abs();
5 | int y = b.abs();
6 | return x >= y ? x * x + x + y : x + y * y;
7 | }
8 |
--------------------------------------------------------------------------------
/lib/src/core/field_types/core_field_type.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
2 |
3 | // ignore: one_member_abstracts
4 | abstract class CoreFieldType {
5 | T deserialize(BinaryReader reader);
6 | }
7 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/interpolator.dart:
--------------------------------------------------------------------------------
1 | abstract class Interpolator {
2 | int get id;
3 |
4 | /// Convert a linear interpolation factor to an eased one.
5 | double transform(double value);
6 |
7 | bool equalParameters(Interpolator other);
8 | }
9 |
--------------------------------------------------------------------------------
/lib/src/local_file_web.dart:
--------------------------------------------------------------------------------
1 | import 'dart:typed_data';
2 |
3 | /// Load a list of bytes from a file on the local filesystem at [path].
4 | Future localFileBytes(String path) =>
5 | throw UnsupportedError('Cannot load from a local file on the web.');
6 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/contour_mesh_vertex.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/shapes/contour_mesh_vertex_base.dart';
2 | export 'package:rive/src/generated/shapes/contour_mesh_vertex_base.dart';
3 |
4 | class ContourMeshVertex extends ContourMeshVertexBase {}
5 |
--------------------------------------------------------------------------------
/lib/src/rive_core/bones/skeletal_component.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/bones/skeletal_component_base.dart';
2 | export 'package:rive/src/generated/bones/skeletal_component_base.dart';
3 |
4 | abstract class SkeletalComponent extends SkeletalComponentBase {}
5 |
--------------------------------------------------------------------------------
/lib/src/rive_core/math/circle_constant.dart:
--------------------------------------------------------------------------------
1 | /// Use this for perfect rounded corners.
2 | /// https://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%A9zier-curves
3 | const circleConstant = 0.552284749831;
4 | const icircleConstant = 1 - circleConstant;
5 |
--------------------------------------------------------------------------------
/example/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/rive_core/event.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/foundation.dart';
2 |
3 | // Just a way to get around the protected notifyListeners so we can use trigger
4 | // multiple events from a single object.
5 | class Event extends ChangeNotifier {
6 | void notify() => notifyListeners();
7 | }
8 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
7 |
--------------------------------------------------------------------------------
/example/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/src/core/field_types/core_int_type.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/field_types/core_field_type.dart';
2 | import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
3 |
4 | class CoreIntType extends CoreFieldType {
5 | @override
6 | int deserialize(BinaryReader reader) => reader.readVarUint();
7 | }
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/src/core/field_types/core_bool_type.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/field_types/core_field_type.dart';
2 | import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
3 |
4 | class CoreBoolType extends CoreFieldType {
5 | @override
6 | bool deserialize(BinaryReader reader) => reader.readInt8() == 1;
7 | }
8 |
--------------------------------------------------------------------------------
/lib/src/core/field_types/core_color_type.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/field_types/core_field_type.dart';
2 | import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
3 |
4 | class CoreColorType extends CoreFieldType {
5 | @override
6 | int deserialize(BinaryReader reader) => reader.readUint32();
7 | }
8 |
--------------------------------------------------------------------------------
/lib/src/core/field_types/core_uint_type.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/field_types/core_field_type.dart';
2 | import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
3 |
4 | class CoreUintType extends CoreFieldType {
5 | @override
6 | int deserialize(BinaryReader reader) => reader.readVarUint();
7 | }
8 |
--------------------------------------------------------------------------------
/lib/src/rive_core/runtime/exceptions/rive_format_error_exception.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 |
3 | /// Thrown when a file being read doesn't match the Rive format.
4 | @immutable
5 | class RiveFormatErrorException implements Exception {
6 | final String cause;
7 | const RiveFormatErrorException(this.cause);
8 | }
9 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/src/core/field_types/core_double_type.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/field_types/core_field_type.dart';
2 | import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
3 |
4 | class CoreDoubleType extends CoreFieldType {
5 | @override
6 | double deserialize(BinaryReader reader) => reader.readFloat32();
7 | }
8 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/blend_animation_1d.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/blend_animation_1d_base.dart';
2 | export 'package:rive/src/generated/animation/blend_animation_1d_base.dart';
3 |
4 | class BlendAnimation1D extends BlendAnimation1DBase {
5 | @override
6 | void valueChanged(double from, double to) {}
7 | }
8 |
--------------------------------------------------------------------------------
/.github/scripts/release/release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | RELEASE_VERSION=`npm run release -- --ci --release-version | tail -n 1`
6 | if ! command -v cider &> /dev/null
7 | then
8 | pub global activate cider
9 | fi
10 |
11 | pushd ../../../
12 | cider version $RELEASE_VERSION
13 | popd
14 |
15 | npm run release -- --ci
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/state_machine_number.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/state_machine_number_base.dart';
2 | export 'package:rive/src/generated/animation/state_machine_number_base.dart';
3 |
4 | class StateMachineNumber extends StateMachineNumberBase {
5 | @override
6 | void valueChanged(double from, double to) {}
7 | }
8 |
--------------------------------------------------------------------------------
/test/src/utils.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 | import 'dart:typed_data';
3 |
4 | /// Loads a Rive file from the assets sub-folder
5 | ByteData loadFile(String filename) {
6 | final file = File(
7 | './${Directory.current.path.endsWith('/test') ? '' : 'test/'}$filename');
8 | return ByteData.sublistView(file.readAsBytesSync());
9 | }
10 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: b9a56b9f48462d897101284f5f57b8568ef683c6
8 | channel: master
9 |
10 | project_type: package
11 |
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 456d80b9ddd74b4b5ca3b77bbfb70ab0e05d3fa8
8 | channel: dev
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/lib/src/core/field_types/core_string_type.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/field_types/core_field_type.dart';
2 | import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
3 |
4 | class CoreStringType extends CoreFieldType {
5 | @override
6 | String deserialize(BinaryReader reader) =>
7 | reader.readString(explicitLength: true);
8 | }
9 |
--------------------------------------------------------------------------------
/lib/src/core/importers/artboard_import_stack_object.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/rive_core/artboard.dart';
3 |
4 | /// An importer that will always resolve with the artboard importer.
5 | abstract class ArtboardImportStackObject extends ImportStackObject {
6 | @override
7 | int get resolvesBefore => ArtboardBase.typeKey;
8 | }
9 |
--------------------------------------------------------------------------------
/lib/src/rive_core/math/path_types.dart:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Rive
3 | */
4 |
5 | enum PathFillRule {
6 | nonZero,
7 | evenOdd,
8 | }
9 |
10 | enum PathDirection {
11 | clockwise,
12 | counterclockwise,
13 | }
14 |
15 | enum PathVerb {
16 | move,
17 | line,
18 | quad,
19 | conicUnused, // so we match skia's order
20 | cubic,
21 | close,
22 | }
23 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/state_machine_trigger.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/state_machine_trigger_base.dart';
2 | export 'package:rive/src/generated/animation/state_machine_trigger_base.dart';
3 |
4 | class StateMachineTrigger extends StateMachineTriggerBase {
5 | void fire() {}
6 |
7 | @override
8 | bool isValidType() => T == bool;
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/any_state.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/any_state_base.dart';
2 | import 'package:rive/src/rive_core/animation/state_instance.dart';
3 |
4 | export 'package:rive/src/generated/animation/any_state_base.dart';
5 |
6 | class AnyState extends AnyStateBase {
7 | @override
8 | StateInstance makeInstance() => SystemStateInstance(this);
9 | }
10 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/exit_state.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/exit_state_base.dart';
2 | import 'package:rive/src/rive_core/animation/state_instance.dart';
3 |
4 | export 'package:rive/src/generated/animation/exit_state_base.dart';
5 |
6 | class ExitState extends ExitStateBase {
7 | @override
8 | StateInstance makeInstance() => SystemStateInstance(this);
9 | }
10 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/entry_state.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/entry_state_base.dart';
2 | import 'package:rive/src/rive_core/animation/state_instance.dart';
3 |
4 | export 'package:rive/src/generated/animation/entry_state_base.dart';
5 |
6 | class EntryState extends EntryStateBase {
7 | @override
8 | StateInstance makeInstance() => SystemStateInstance(this);
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/state_machine_bool.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/state_machine_bool_base.dart';
2 | export 'package:rive/src/generated/animation/state_machine_bool_base.dart';
3 |
4 | class StateMachineBool extends StateMachineBoolBase {
5 | @override
6 | void valueChanged(bool from, bool to) {}
7 |
8 | @override
9 | bool isValidType() => T == bool;
10 | }
11 |
--------------------------------------------------------------------------------
/.github/scripts/release/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "release",
3 | "description": "",
4 | "scripts": {
5 | "release": "release-it"
6 | },
7 | "author": "",
8 | "license": "ISC",
9 | "devDependencies": {
10 | "@release-it/bumper": "^2.0.0",
11 | "auto-changelog": "^2.3.0",
12 | "release-it": "^14.11.0"
13 | },
14 | "version": "0.8.4"
15 | }
16 |
--------------------------------------------------------------------------------
/lib/src/rive_core/assets/asset.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/assets/asset_base.dart';
2 |
3 | export 'package:rive/src/generated/assets/asset_base.dart';
4 |
5 | class Asset extends AssetBase {
6 | @override
7 | void nameChanged(String from, String to) {}
8 |
9 | @override
10 | void onAdded() {}
11 |
12 | @override
13 | void onAddedDirty() {}
14 |
15 | bool get isUsable => false;
16 | }
17 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/loop.dart:
--------------------------------------------------------------------------------
1 | /// Loop options for linear animations.
2 | enum Loop {
3 | /// Play until the duration or end of work area of the animation.
4 | oneShot,
5 |
6 | /// Play until the duration or end of work area of the animation and then go
7 | /// back to the start (0 seconds).
8 | loop,
9 |
10 | /// Play to the end of the duration/work area and then play back.
11 | pingPong,
12 | }
13 |
--------------------------------------------------------------------------------
/lib/src/rive_core/bones/root_bone.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/bones/root_bone_base.dart';
2 | export 'package:rive/src/generated/bones/root_bone_base.dart';
3 |
4 | class RootBone extends RootBoneBase {
5 | @override
6 | void xChanged(double from, double to) {
7 | markTransformDirty();
8 | }
9 |
10 | @override
11 | void yChanged(double from, double to) {
12 | markTransformDirty();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/generated/asset_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/asset_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/core/core.dart';
5 |
6 | abstract class AssetBase extends Core {
7 | static const int typeKey = 99;
8 | @override
9 | int get coreType => AssetBase.typeKey;
10 | @override
11 | Set get coreTypes => {AssetBase.typeKey};
12 | }
13 |
--------------------------------------------------------------------------------
/lib/src/core/field_types/core_bytes_type.dart:
--------------------------------------------------------------------------------
1 | import 'dart:typed_data';
2 |
3 | import 'package:rive/src/core/field_types/core_field_type.dart';
4 | import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
5 |
6 | class CoreBytesType extends CoreFieldType {
7 | @override
8 | Uint8List deserialize(BinaryReader reader) {
9 | var length = reader.readVarUint();
10 | return reader.read(length);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/lib/src/generated/backboard_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/backboard_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/core/core.dart';
5 |
6 | abstract class BackboardBase extends Core {
7 | static const int typeKey = 23;
8 | @override
9 | int get coreType => BackboardBase.typeKey;
10 | @override
11 | Set get coreTypes => {BackboardBase.typeKey};
12 | }
13 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/keyframe_interpolation.dart:
--------------------------------------------------------------------------------
1 | /// The type of interpolation used for a keyframe.
2 | enum KeyFrameInterpolation {
3 | /// Hold the incoming value until the next keyframe is reached.
4 | hold,
5 |
6 | /// Linearly interpolate from the incoming to the outgoing value.
7 | linear,
8 |
9 | /// Cubicly interpolate from incoming to outgoing value based on the
10 | /// [CubicInterpolator]'s parameters.
11 | cubic,
12 | }
13 |
--------------------------------------------------------------------------------
/lib/src/generated/assets/folder_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/assets/folder_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/rive_core/assets/asset.dart';
5 |
6 | abstract class FolderBase extends Asset {
7 | static const int typeKey = 102;
8 | @override
9 | int get coreType => FolderBase.typeKey;
10 | @override
11 | Set get coreTypes => {FolderBase.typeKey, AssetBase.typeKey};
12 | }
13 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/event_trigger_change.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/event_trigger_change_base.dart';
2 | import 'package:rive/src/rive_core/state_machine_controller.dart';
3 |
4 | export 'package:rive/src/generated/animation/event_trigger_change_base.dart';
5 |
6 | class EventTriggerChange extends EventTriggerChangeBase {
7 | @override
8 | void perform(StateMachineController controller) =>
9 | controller.setInputValue(inputId, true);
10 | }
11 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController.init()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/.github/scripts/release/changelog.hbs:
--------------------------------------------------------------------------------
1 | {{#each releases}}
2 | {{#if @first}}
3 | ## {{title}}{{#if tag}} ({{isoDate}}){{/if}}
4 | {{#each merges}}
5 | - {{{message}}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}
6 | {{/each}}
7 | {{#each fixes}}
8 | - {{{commit.subject}}}{{#each fixes}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}{{/each}}
9 | {{/each}}
10 | {{#each commits}}{{#if breaking}}**Breaking change:** {{{subject}}}{{#if href}}[`{{shorthash}}`]({{href}}){{/if}}
11 | {{/if}}{{/each}}
12 | {{/if}}
13 | {{/each}}
--------------------------------------------------------------------------------
/example/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.client
10 |
11 | com.apple.security.network.server
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/path_composer_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/shapes/path_composer_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/component.dart';
6 |
7 | abstract class PathComposerBase extends Component {
8 | static const int typeKey = 9;
9 | @override
10 | int get coreType => PathComposerBase.typeKey;
11 | @override
12 | Set get coreTypes => {PathComposerBase.typeKey, ComponentBase.typeKey};
13 | }
14 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/path_vertex.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/shapes/path_vertex_base.dart';
2 | import 'package:rive/src/rive_core/bones/weight.dart';
3 | import 'package:rive/src/rive_core/shapes/path.dart';
4 |
5 | export 'package:rive/src/generated/shapes/path_vertex_base.dart';
6 |
7 | abstract class PathVertex extends PathVertexBase {
8 | Path? get path => parent as Path?;
9 |
10 | @override
11 | void markGeometryDirty() => path?.markPathDirty();
12 | }
13 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: rive_example
2 | description: A collection of Rive Flutter examples
3 |
4 | publish_to: "none" # Remove this line if you wish to publish to pub.dev
5 |
6 | version: 1.0.0+1
7 |
8 | environment:
9 | sdk: ">=2.12.0 <3.0.0"
10 |
11 | dependencies:
12 | flutter:
13 | sdk: flutter
14 | rive:
15 | path: ../
16 |
17 | dev_dependencies:
18 | flutter_test:
19 | sdk: flutter
20 |
21 | flutter:
22 | uses-material-design: true
23 |
24 | assets:
25 | - assets/
26 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/state_machine_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/state_machine_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/animation.dart';
6 |
7 | abstract class StateMachineBase extends Animation {
8 | static const int typeKey = 53;
9 | @override
10 | int get coreType => StateMachineBase.typeKey;
11 | @override
12 | Set get coreTypes => {StateMachineBase.typeKey, AnimationBase.typeKey};
13 | }
14 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/blend_state_direct.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/blend_state_direct_base.dart';
2 | import 'package:rive/src/rive_core/animation/blend_state_direct_instance.dart';
3 | import 'package:rive/src/rive_core/animation/state_instance.dart';
4 |
5 | export 'package:rive/src/generated/animation/blend_state_direct_base.dart';
6 |
7 | class BlendStateDirect extends BlendStateDirectBase {
8 | @override
9 | StateInstance makeInstance() => BlendStateDirectInstance(this);
10 | }
11 |
--------------------------------------------------------------------------------
/lib/src/generated/container_component_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/container_component_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/component.dart';
6 |
7 | abstract class ContainerComponentBase extends Component {
8 | static const int typeKey = 11;
9 | @override
10 | int get coreType => ContainerComponentBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {ContainerComponentBase.typeKey, ComponentBase.typeKey};
14 | }
15 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/lib/src/rive_core/assets/drawable_asset.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/assets/drawable_asset_base.dart';
2 | export 'package:rive/src/generated/assets/drawable_asset_base.dart';
3 |
4 | abstract class DrawableAsset extends DrawableAssetBase {
5 | @override
6 | bool get isUsable => width != 0 && height != 0;
7 |
8 | @override
9 | void heightChanged(double from, double to) {}
10 |
11 | @override
12 | void widthChanged(double from, double to) {}
13 |
14 | @override
15 | void assetIdChanged(int from, int to) {}
16 | }
17 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/nested_state_machine.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/nested_state_machine_base.dart';
2 | import 'package:rive/src/rive_core/nested_artboard.dart';
3 |
4 | export 'package:rive/src/generated/animation/nested_state_machine_base.dart';
5 |
6 | class NestedStateMachine extends NestedStateMachineBase {
7 | @override
8 | void advance(double elapsedSeconds, MountedArtboard mountedArtboard) {
9 | // TODO: implement advance
10 | }
11 |
12 | @override
13 | bool get isEnabled => false;
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/state_machine_layer_component.dart:
--------------------------------------------------------------------------------
1 | // We really want this file to import core for the flutter runtime, so make the
2 | // linter happy...
3 |
4 | // ignore: unused_import
5 | import 'package:rive/src/core/core.dart';
6 |
7 | import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
8 | export 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
9 |
10 | abstract class StateMachineLayerComponent
11 | extends StateMachineLayerComponentBase {}
12 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/transition_value_condition.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/transition_value_condition_base.dart';
2 | import 'package:rive/src/rive_core/animation/transition_condition.dart';
3 |
4 | export 'package:rive/src/generated/animation/transition_value_condition_base.dart';
5 |
6 | abstract class TransitionValueCondition extends TransitionValueConditionBase {
7 | TransitionConditionOp get op => TransitionConditionOp.values[opValue];
8 |
9 | @override
10 | void opValueChanged(int from, int to) {}
11 | }
12 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/event_number_change.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/event_number_change_base.dart';
2 | import 'package:rive/src/rive_core/state_machine_controller.dart';
3 |
4 | export 'package:rive/src/generated/animation/event_number_change_base.dart';
5 |
6 | class EventNumberChange extends EventNumberChangeBase {
7 | @override
8 | void valueChanged(double from, double to) {}
9 |
10 | @override
11 | void perform(StateMachineController controller) =>
12 | controller.setInputValue(inputId, value);
13 | }
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/layer_state_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/layer_state_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/state_machine_layer_component.dart';
6 |
7 | abstract class LayerStateBase extends StateMachineLayerComponent {
8 | static const int typeKey = 60;
9 | @override
10 | int get coreType => LayerStateBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {LayerStateBase.typeKey, StateMachineLayerComponentBase.typeKey};
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/state_machine_layer_component_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/state_machine_layer_component_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/core/core.dart';
6 |
7 | abstract class StateMachineLayerComponentBase
8 | extends Core {
9 | static const int typeKey = 66;
10 | @override
11 | int get coreType => StateMachineLayerComponentBase.typeKey;
12 | @override
13 | Set get coreTypes => {StateMachineLayerComponentBase.typeKey};
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/core/importers/linear_animation_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/rive.dart';
2 | import 'package:rive/src/core/importers/artboard_import_stack_object.dart';
3 | import 'package:rive/src/rive_core/animation/keyed_object.dart';
4 |
5 | class LinearAnimationImporter extends ArtboardImportStackObject {
6 | final LinearAnimation linearAnimation;
7 | LinearAnimationImporter(this.linearAnimation);
8 |
9 | void addKeyedObject(KeyedObject object) {
10 | linearAnimation.context.addObject(object);
11 | linearAnimation.internalAddKeyedObject(object);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/lib/src/core/importers/state_machine_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/importers/artboard_import_stack_object.dart';
2 | import 'package:rive/src/rive_core/animation/state_machine.dart';
3 | import 'package:rive/src/rive_core/animation/state_machine_component.dart';
4 |
5 | class StateMachineImporter extends ArtboardImportStackObject {
6 | final StateMachine machine;
7 | StateMachineImporter(this.machine);
8 |
9 | void addMachineComponent(StateMachineComponent object) {
10 | machine.context.addObject(object);
11 | object.stateMachine = machine;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/event_trigger_change_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/event_trigger_change_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/event_input_change.dart';
6 |
7 | abstract class EventTriggerChangeBase extends EventInputChange {
8 | static const int typeKey = 115;
9 | @override
10 | int get coreType => EventTriggerChangeBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {EventTriggerChangeBase.typeKey, EventInputChangeBase.typeKey};
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/state_machine_input_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/state_machine_input_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/state_machine_component.dart';
6 |
7 | abstract class StateMachineInputBase extends StateMachineComponent {
8 | static const int typeKey = 55;
9 | @override
10 | int get coreType => StateMachineInputBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {StateMachineInputBase.typeKey, StateMachineComponentBase.typeKey};
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/state_machine_layer_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/state_machine_layer_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/state_machine_component.dart';
6 |
7 | abstract class StateMachineLayerBase extends StateMachineComponent {
8 | static const int typeKey = 57;
9 | @override
10 | int get coreType => StateMachineLayerBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {StateMachineLayerBase.typeKey, StateMachineComponentBase.typeKey};
14 | }
15 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: rive
2 | description: Rive 2 Flutter Runtime. This package provides runtime functionality for playing back and interacting with animations built with the Rive editor available at https://rive.app.
3 | version: 0.8.4
4 | repository: https://github.com/rive-app/rive-flutter
5 | homepage: https://rive.app
6 |
7 | environment:
8 | sdk: ">=2.12.0 <3.0.0"
9 |
10 | dependencies:
11 | collection: ^1.15.0
12 | flutter:
13 | sdk: flutter
14 | graphs: ^2.0.0
15 | http: ^0.13.3
16 | meta: ^1.3.0
17 |
18 | dev_dependencies:
19 | flutter_test:
20 | sdk: flutter
21 |
--------------------------------------------------------------------------------
/lib/src/core/importers/keyed_object_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/importers/artboard_import_stack_object.dart';
2 | import 'package:rive/src/rive_core/animation/keyed_object.dart';
3 | import 'package:rive/src/rive_core/animation/keyed_property.dart';
4 |
5 | class KeyedObjectImporter extends ArtboardImportStackObject {
6 | final KeyedObject keyedObject;
7 |
8 | KeyedObjectImporter(this.keyedObject);
9 |
10 | void addKeyedProperty(KeyedProperty property) {
11 | keyedObject.context.addObject(property);
12 | keyedObject.internalAddKeyedProperty(property);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/blend_animations.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 |
3 | import 'package:rive/src/rive_core/animation/blend_animation.dart';
4 |
5 | class BlendAnimations extends ListBase {
6 | final List _values = [];
7 | List get values => _values.cast();
8 |
9 | @override
10 | int get length => _values.length;
11 |
12 | @override
13 | set length(int value) => _values.length = value;
14 |
15 | @override
16 | T operator [](int index) => _values[index]!;
17 |
18 | @override
19 | void operator []=(int index, T value) => _values[index] = value;
20 | }
21 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # rive_example
2 |
3 | A new Flutter project.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/lib/src/asset_list.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 |
3 | import 'package:rive/src/rive_core/assets/asset.dart';
4 |
5 | // List of assets used by the backboard.
6 | class AssetList extends ListBase {
7 | final List _values = [];
8 | List get values => _values.cast();
9 |
10 | @override
11 | int get length => _values.length;
12 |
13 | @override
14 | set length(int value) => _values.length = value;
15 |
16 | @override
17 | Asset operator [](int index) => _values[index]!;
18 |
19 | @override
20 | void operator []=(int index, Asset value) => _values[index] = value;
21 | }
22 |
--------------------------------------------------------------------------------
/example/lib/simple_animation.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:rive/rive.dart';
3 |
4 | class SimpleAnimation extends StatelessWidget {
5 | const SimpleAnimation({Key? key}) : super(key: key);
6 |
7 | @override
8 | Widget build(BuildContext context) {
9 | return Scaffold(
10 | appBar: AppBar(
11 | title: const Text('Simple Animation'),
12 | ),
13 | body: const Center(
14 | child: RiveAnimation.network(
15 | 'https://cdn.rive.app/animations/vehicles.riv',
16 | fit: BoxFit.cover,
17 | ),
18 | ),
19 | );
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/transition_trigger_condition_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/transition_trigger_condition_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/transition_condition.dart';
6 |
7 | abstract class TransitionTriggerConditionBase extends TransitionCondition {
8 | static const int typeKey = 68;
9 | @override
10 | int get coreType => TransitionTriggerConditionBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {TransitionTriggerConditionBase.typeKey, TransitionConditionBase.typeKey};
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/state_machine_components.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 | import 'package:rive/src/rive_core/animation/state_machine_component.dart';
3 |
4 | class StateMachineComponents
5 | extends ListBase {
6 | final List _values = [];
7 | List get values => _values.cast();
8 |
9 | @override
10 | int get length => _values.length;
11 |
12 | @override
13 | set length(int value) => _values.length = value;
14 |
15 | @override
16 | T operator [](int index) => _values[index]!;
17 |
18 | @override
19 | void operator []=(int index, T value) => _values[index] = value;
20 | }
21 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/mesh_vertex.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/shapes/mesh_vertex_base.dart';
2 | import 'package:rive/src/rive_core/shapes/mesh.dart';
3 |
4 | export 'package:rive/src/generated/shapes/mesh_vertex_base.dart';
5 |
6 | class MeshVertex extends MeshVertexBase {
7 | Mesh? get mesh => parent as Mesh?;
8 |
9 | @override
10 | bool validate() => super.validate() && parent is Mesh;
11 |
12 | @override
13 | void markGeometryDirty() => mesh?.markDrawableDirty();
14 |
15 | @override
16 | void uChanged(double from, double to) {}
17 |
18 | @override
19 | void vChanged(double from, double to) {}
20 | }
21 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/paint/radial_gradient.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui' as ui;
2 | import 'package:rive/src/generated/shapes/paint/radial_gradient_base.dart';
3 | export 'package:rive/src/generated/shapes/paint/radial_gradient_base.dart';
4 |
5 | class RadialGradient extends RadialGradientBase {
6 | /// We override the make gradient operation to create a radial gradient
7 | /// instead of a linear one.
8 | @override
9 | ui.Gradient makeGradient(ui.Offset start, ui.Offset end,
10 | List colors, List colorPositions) =>
11 | ui.Gradient.radial(start, (end - start).distance, colors, colorPositions);
12 | }
13 |
--------------------------------------------------------------------------------
/lib/src/container_children.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 | import 'package:rive/src/rive_core/component.dart';
3 |
4 | // TODO: figure out how to make this cleaner.
5 | class ContainerChildren extends ListBase {
6 | final List _values = [];
7 | List get values => _values.cast();
8 |
9 | @override
10 | int get length => _values.length;
11 |
12 | @override
13 | set length(int value) => _values.length = value;
14 |
15 | @override
16 | Component operator [](int index) => _values[index]!;
17 |
18 | @override
19 | void operator []=(int index, Component value) => _values[index] = value;
20 | }
21 |
--------------------------------------------------------------------------------
/lib/src/state_transitions.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 | import 'package:rive/src/rive_core/animation/state_transition.dart';
3 |
4 | class StateTransitions extends ListBase {
5 | final List _values = [];
6 | List get values => _values.cast();
7 |
8 | @override
9 | int get length => _values.length;
10 |
11 | @override
12 | set length(int value) => _values.length = value;
13 |
14 | @override
15 | StateTransition operator [](int index) => _values[index]!;
16 |
17 | @override
18 | void operator []=(int index, StateTransition value) => _values[index] = value;
19 | }
20 |
--------------------------------------------------------------------------------
/lib/src/rive_core/state_transition_flags.dart:
--------------------------------------------------------------------------------
1 | class StateTransitionFlags {
2 | /// Whether the transition is disabled.
3 | static const int disabled = 1 << 0;
4 |
5 | /// Whether the transition duration is a percentage or time in ms.
6 | static const int durationIsPercentage = 1 << 1;
7 |
8 | /// Whether exit time is enabled.
9 | static const int enableExitTime = 1 << 2;
10 |
11 | /// Whether the exit time is a percentage or time in ms.
12 | static const int exitTimeIsPercentage = 1 << 3;
13 |
14 | /// Whether the animation is held at exit or if it keeps advancing during
15 | /// mixing.
16 | static const int pauseOnExit = 1 << 4;
17 | }
18 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/lib/src/input_changes.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 | import 'package:rive/src/rive_core/animation/event_input_change.dart';
3 |
4 | class InputChanges extends ListBase {
5 | final List _values = [];
6 | List get values => _values.cast();
7 |
8 | @override
9 | int get length => _values.length;
10 |
11 | @override
12 | set length(int value) => _values.length = value;
13 |
14 | @override
15 | EventInputChange operator [](int index) => _values[index]!;
16 |
17 | @override
18 | void operator []=(int index, EventInputChange value) =>
19 | _values[index] = value;
20 | }
21 |
--------------------------------------------------------------------------------
/lib/src/rive_core/bones/cubic_weight.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/bones/cubic_weight_base.dart';
2 | import 'package:rive/src/rive_core/math/vec2d.dart';
3 |
4 | export 'package:rive/src/generated/bones/cubic_weight_base.dart';
5 |
6 | class CubicWeight extends CubicWeightBase {
7 | final Vec2D inTranslation = Vec2D();
8 | final Vec2D outTranslation = Vec2D();
9 |
10 | @override
11 | void inIndicesChanged(int from, int to) {}
12 |
13 | @override
14 | void inValuesChanged(int from, int to) {}
15 |
16 | @override
17 | void outIndicesChanged(int from, int to) {}
18 |
19 | @override
20 | void outValuesChanged(int from, int to) {}
21 | }
22 |
--------------------------------------------------------------------------------
/lib/src/core/importers/state_machine_event_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/importers/artboard_import_stack_object.dart';
2 | import 'package:rive/src/rive_core/animation/event_input_change.dart';
3 | import 'package:rive/src/rive_core/animation/state_machine_event.dart';
4 |
5 | class StateMachineEventImporter extends ArtboardImportStackObject {
6 | final StateMachineEvent event;
7 | StateMachineEventImporter(this.event);
8 |
9 | void addInputChange(EventInputChange change) {
10 | // Other state machine importers do this, do we really need it?
11 | // event.context.addObject(change);
12 | event.internalAddInputChange(change);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/rive_core/node.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/node_base.dart';
2 | import 'package:rive/src/rive_core/math/vec2d.dart';
3 |
4 | export 'package:rive/src/generated/node_base.dart';
5 |
6 | class _UnknownNode extends Node {}
7 |
8 | class Node extends NodeBase {
9 | static final Node unknown = _UnknownNode();
10 |
11 | /// Sets the position of the Node
12 | set translation(Vec2D pos) {
13 | x = pos.x;
14 | y = pos.y;
15 | }
16 |
17 | @override
18 | void xChanged(double from, double to) {
19 | markTransformDirty();
20 | }
21 |
22 | @override
23 | void yChanged(double from, double to) {
24 | markTransformDirty();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/any_state_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/any_state_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
6 | import 'package:rive/src/rive_core/animation/layer_state.dart';
7 |
8 | abstract class AnyStateBase extends LayerState {
9 | static const int typeKey = 62;
10 | @override
11 | int get coreType => AnyStateBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | AnyStateBase.typeKey,
15 | LayerStateBase.typeKey,
16 | StateMachineLayerComponentBase.typeKey
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/exit_state_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/exit_state_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
6 | import 'package:rive/src/rive_core/animation/layer_state.dart';
7 |
8 | abstract class ExitStateBase extends LayerState {
9 | static const int typeKey = 64;
10 | @override
11 | int get coreType => ExitStateBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | ExitStateBase.typeKey,
15 | LayerStateBase.typeKey,
16 | StateMachineLayerComponentBase.typeKey
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = example
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved.
15 |
--------------------------------------------------------------------------------
/lib/src/animation_list.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 | import 'package:rive/src/rive_core/animation/animation.dart';
3 |
4 | class AnimationList extends ListBase {
5 | // Lame way to do this due to how ListBase needs to expand a nullable list.
6 | final List _values = [];
7 | List get values => _values.cast();
8 |
9 | @override
10 | int get length => _values.length;
11 |
12 | @override
13 | set length(int value) => _values.length = value;
14 |
15 | @override
16 | Animation operator [](int index) => _values[index]!;
17 |
18 | @override
19 | void operator []=(int index, Animation value) => _values[index] = value;
20 | }
21 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/blend_state_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/blend_state_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
6 | import 'package:rive/src/rive_core/animation/layer_state.dart';
7 |
8 | abstract class BlendStateBase extends LayerState {
9 | static const int typeKey = 72;
10 | @override
11 | int get coreType => BlendStateBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | BlendStateBase.typeKey,
15 | LayerStateBase.typeKey,
16 | StateMachineLayerComponentBase.typeKey
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/entry_state_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/entry_state_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
6 | import 'package:rive/src/rive_core/animation/layer_state.dart';
7 |
8 | abstract class EntryStateBase extends LayerState {
9 | static const int typeKey = 63;
10 | @override
11 | int get coreType => EntryStateBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | EntryStateBase.typeKey,
15 | LayerStateBase.typeKey,
16 | StateMachineLayerComponentBase.typeKey
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/example/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rive_example",
3 | "short_name": "rive_example",
4 | "start_url": ".",
5 | "display": "standalone",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "A new Flutter project.",
9 | "orientation": "portrait-primary",
10 | "prefer_related_applications": false,
11 | "icons": [
12 | {
13 | "src": "icons/Icon-192.png",
14 | "sizes": "192x192",
15 | "type": "image/png"
16 | },
17 | {
18 | "src": "icons/Icon-512.png",
19 | "sizes": "512x512",
20 | "type": "image/png"
21 | }
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Flutter.podspec
20 | Flutter/Generated.xcconfig
21 | Flutter/app.flx
22 | Flutter/app.zip
23 | Flutter/flutter_assets/
24 | Flutter/flutter_export_environment.sh
25 | ServiceDefinitions.json
26 | Runner/GeneratedPluginRegistrant.*
27 |
28 | # Exceptions to above rules.
29 | !default.mode1v3
30 | !default.mode2v3
31 | !default.pbxuser
32 | !default.perspectivev3
33 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Flutter Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style license that can be
3 | // found in the LICENSE file.
4 |
5 | include ':app'
6 |
7 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
8 | def properties = new Properties()
9 |
10 | assert localPropertiesFile.exists()
11 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12 |
13 | def flutterSdkPath = properties.getProperty("flutter.sdk")
14 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
15 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
16 |
--------------------------------------------------------------------------------
/lib/src/state_transition_conditions.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 | import 'package:rive/src/rive_core/animation/transition_condition.dart';
3 |
4 | class StateTransitionConditions extends ListBase {
5 | final List _values = [];
6 | List get values => _values.cast();
7 |
8 | @override
9 | int get length => _values.length;
10 |
11 | @override
12 | set length(int value) => _values.length = value;
13 |
14 | @override
15 | TransitionCondition operator [](int index) => _values[index]!;
16 |
17 | @override
18 | void operator []=(int index, TransitionCondition value) =>
19 | _values[index] = value;
20 | }
21 |
--------------------------------------------------------------------------------
/.github/workflows/tests.yaml:
--------------------------------------------------------------------------------
1 | name: Tests
2 |
3 | on:
4 | push:
5 |
6 | jobs:
7 | build:
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v2
12 |
13 | - name: Checkout and install Flutter
14 | run: git clone https://github.com/flutter/flutter.git
15 |
16 | - name: Add the Flutter path
17 | run: echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH
18 |
19 | - name: Set Flutter root
20 | run: echo "FLUTTER_ROOT=$GITHUB_WORKSPACE/flutter" >> $GITHUB_ENV
21 |
22 | - name: Setup flutter
23 | run: |
24 | flutter channel stable
25 | flutter doctor
26 |
27 | - name: Run tests
28 | run: flutter test
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.50'
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.5.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | jcenter()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/lib/src/generated/assets/image_asset_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/assets/image_asset_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/generated/assets/asset_base.dart';
5 | import 'package:rive/src/generated/assets/file_asset_base.dart';
6 | import 'package:rive/src/rive_core/assets/drawable_asset.dart';
7 |
8 | abstract class ImageAssetBase extends DrawableAsset {
9 | static const int typeKey = 105;
10 | @override
11 | int get coreType => ImageAssetBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | ImageAssetBase.typeKey,
15 | DrawableAssetBase.typeKey,
16 | FileAssetBase.typeKey,
17 | AssetBase.typeKey
18 | };
19 | }
20 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/state_machine_trigger_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/state_machine_trigger_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/state_machine_component_base.dart';
6 | import 'package:rive/src/rive_core/animation/state_machine_input.dart';
7 |
8 | abstract class StateMachineTriggerBase extends StateMachineInput {
9 | static const int typeKey = 58;
10 | @override
11 | int get coreType => StateMachineTriggerBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | StateMachineTriggerBase.typeKey,
15 | StateMachineInputBase.typeKey,
16 | StateMachineComponentBase.typeKey
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/lib/src/rive_core/nested_animation.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/nested_animation_base.dart';
2 | import 'package:rive/src/rive_core/animation/animation.dart';
3 | import 'package:rive/src/rive_core/nested_artboard.dart';
4 |
5 | export 'package:rive/src/generated/nested_animation_base.dart';
6 |
7 | abstract class NestedAnimation
8 | extends NestedAnimationBase {
9 | NestedArtboard? get nestedArtboard =>
10 | parent is NestedArtboard ? parent as NestedArtboard : null;
11 |
12 | @override
13 | void animationIdChanged(int from, int to) {}
14 |
15 |
16 | bool get isEnabled;
17 | void advance(double elapsedSeconds, MountedArtboard mountedArtboard);
18 |
19 | @override
20 | void update(int dirt) {}
21 | }
22 |
--------------------------------------------------------------------------------
/lib/src/core/importers/keyed_property_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/importers/artboard_import_stack_object.dart';
2 | import 'package:rive/src/rive_core/animation/keyed_property.dart';
3 | import 'package:rive/src/rive_core/animation/keyframe.dart';
4 | import 'package:rive/src/rive_core/animation/linear_animation.dart';
5 |
6 | class KeyedPropertyImporter extends ArtboardImportStackObject {
7 | final KeyedProperty keyedProperty;
8 | final LinearAnimation animation;
9 |
10 | KeyedPropertyImporter(this.keyedProperty, this.animation);
11 |
12 | void addKeyFrame(KeyFrame keyFrame) {
13 | keyedProperty.context.addObject(keyFrame);
14 | keyedProperty.internalAddKeyFrame(keyFrame);
15 | keyFrame.computeSeconds(animation);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/nested_state_machine_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/nested_state_machine_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/rive_core/animation/state_machine.dart';
7 | import 'package:rive/src/rive_core/nested_animation.dart';
8 |
9 | abstract class NestedStateMachineBase extends NestedAnimation {
10 | static const int typeKey = 95;
11 | @override
12 | int get coreType => NestedStateMachineBase.typeKey;
13 | @override
14 | Set get coreTypes => {
15 | NestedStateMachineBase.typeKey,
16 | NestedAnimationBase.typeKey,
17 | ComponentBase.typeKey
18 | };
19 | }
20 |
--------------------------------------------------------------------------------
/lib/src/rive_core/runtime/exceptions/rive_unsupported_version_exception.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 |
3 | /// Error that occurs when a file being loaded doesn't match the importer's
4 | /// supported version.
5 | @immutable
6 | class RiveUnsupportedVersionException implements Exception {
7 | final int majorVersion;
8 | final int minorVersion;
9 | final int fileMajorVersion;
10 | final int fileMinorVersion;
11 | const RiveUnsupportedVersionException(this.majorVersion, this.minorVersion,
12 | this.fileMajorVersion, this.fileMinorVersion);
13 |
14 | @override
15 | String toString() {
16 | return 'File contains version $fileMajorVersion.$fileMinorVersion. '
17 | 'This runtime supports version $majorVersion.$minorVersion';
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/transition_bool_condition_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/transition_bool_condition_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/transition_condition_base.dart';
6 | import 'package:rive/src/rive_core/animation/transition_value_condition.dart';
7 |
8 | abstract class TransitionBoolConditionBase extends TransitionValueCondition {
9 | static const int typeKey = 71;
10 | @override
11 | int get coreType => TransitionBoolConditionBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | TransitionBoolConditionBase.typeKey,
15 | TransitionValueConditionBase.typeKey,
16 | TransitionConditionBase.typeKey
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/paint/radial_gradient_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/shapes/paint/radial_gradient_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/generated/container_component_base.dart';
7 | import 'package:rive/src/rive_core/shapes/paint/linear_gradient.dart';
8 |
9 | abstract class RadialGradientBase extends LinearGradient {
10 | static const int typeKey = 17;
11 | @override
12 | int get coreType => RadialGradientBase.typeKey;
13 | @override
14 | Set get coreTypes => {
15 | RadialGradientBase.typeKey,
16 | LinearGradientBase.typeKey,
17 | ContainerComponentBase.typeKey,
18 | ComponentBase.typeKey
19 | };
20 | }
21 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/keyframe_id.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/animation/keyframe_id_base.dart';
3 | export 'package:rive/src/generated/animation/keyframe_id_base.dart';
4 |
5 | class KeyFrameId extends KeyFrameIdBase {
6 | @override
7 | bool get canInterpolate => false;
8 |
9 | @override
10 | void apply(Core object, int propertyKey, double mix) {
11 | RiveCoreContext.setUint(object, propertyKey, value);
12 | }
13 |
14 | @override
15 | void applyInterpolation(Core object, int propertyKey,
16 | double currentTime, KeyFrameId nextFrame, double mix) {
17 | RiveCoreContext.setUint(object, propertyKey, value);
18 | }
19 |
20 | @override
21 | void valueChanged(int from, int to) {}
22 | }
23 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/path_vertex_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/shapes/path_vertex_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/generated/component_base.dart';
5 | import 'package:rive/src/generated/container_component_base.dart';
6 | import 'package:rive/src/rive_core/bones/weight.dart';
7 | import 'package:rive/src/rive_core/shapes/vertex.dart';
8 |
9 | abstract class PathVertexBase extends Vertex {
10 | static const int typeKey = 14;
11 | @override
12 | int get coreType => PathVertexBase.typeKey;
13 | @override
14 | Set get coreTypes => {
15 | PathVertexBase.typeKey,
16 | VertexBase.typeKey,
17 | ContainerComponentBase.typeKey,
18 | ComponentBase.typeKey
19 | };
20 | }
21 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/blend_state.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/animation/blend_state_base.dart';
3 | import 'package:rive/src/rive_core/animation/blend_animation.dart';
4 |
5 | export 'package:rive/src/generated/animation/blend_state_base.dart';
6 |
7 | //
8 | abstract class BlendState extends BlendStateBase {
9 | final BlendAnimations _animations = BlendAnimations();
10 | BlendAnimations get animations => _animations;
11 |
12 | void internalAddAnimation(T animation) {
13 | assert(!_animations.contains(animation),
14 | 'shouldn\'t already contain the animation');
15 | _animations.add(animation);
16 | }
17 |
18 | void internalRemoveAnimation(T animation) {
19 | _animations.remove(animation);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/src/utilities/tops.dart:
--------------------------------------------------------------------------------
1 | abstract class Parentable {
2 | T? get parent;
3 | }
4 |
5 | /// Get the top most components (any child that has an ancestor in the set
6 | /// should be pruned).
7 | Set tops>(Iterable parentables) {
8 | var tips = {};
9 | outerLoop:
10 | for (final item in parentables) {
11 | for (T? parent = item.parent; parent != null; parent = parent.parent) {
12 | if (parentables.contains(parent)) {
13 | continue outerLoop;
14 | }
15 | }
16 | tips.add(item);
17 | }
18 | return tips;
19 | }
20 |
21 | bool isChildOf>(T child, Iterable parents) {
22 | for (T? parent = child; parent != null; parent = parent.parent) {
23 | if (parents.contains(parent)) {
24 | return true;
25 | }
26 | }
27 | return false;
28 | }
29 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/transition_trigger_condition.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 |
3 | import 'package:rive/src/generated/animation/transition_trigger_condition_base.dart';
4 | import 'package:rive/src/rive_core/animation/state_machine_trigger.dart';
5 |
6 | export 'package:rive/src/generated/animation/transition_trigger_condition_base.dart';
7 |
8 | class TransitionTriggerCondition extends TransitionTriggerConditionBase {
9 | @override
10 | bool validate() => super.validate() && (input is StateMachineTrigger);
11 |
12 | @override
13 | bool evaluate(HashMap values) {
14 | if (input is! StateMachineTrigger) {
15 | return true;
16 | }
17 | dynamic providedValue = values[input.id];
18 | if (providedValue is bool && providedValue) {
19 | return true;
20 | }
21 | return false;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/state_machine_input.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: use_setters_to_change_properties
2 |
3 | import 'dart:collection';
4 |
5 | import 'package:rive/src/generated/animation/state_machine_input_base.dart';
6 | import 'package:rive/src/rive_core/animation/state_machine.dart';
7 | import 'package:rive/src/rive_core/animation/state_machine_component.dart';
8 |
9 | export 'package:rive/src/generated/animation/state_machine_input_base.dart';
10 |
11 | abstract class StateMachineInput extends StateMachineInputBase {
12 | static final StateMachineInput unknown = _StateMachineUnknownInput();
13 |
14 | @override
15 | ListBase machineComponentList(StateMachine machine) =>
16 | machine.inputs;
17 |
18 | bool isValidType() => false;
19 | }
20 |
21 | class _StateMachineUnknownInput extends StateMachineInput {}
22 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/keyframe_bool.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/animation/keyframe_bool_base.dart';
3 | export 'package:rive/src/generated/animation/keyframe_bool_base.dart';
4 |
5 | /// KeyFrame for animating bool properties.
6 | class KeyFrameBool extends KeyFrameBoolBase {
7 | @override
8 | bool get canInterpolate => false;
9 |
10 | @override
11 | void apply(Core object, int propertyKey, double mix) {
12 | RiveCoreContext.setBool(object, propertyKey, value);
13 | }
14 |
15 | @override
16 | void applyInterpolation(Core object, int propertyKey,
17 | double currentTime, KeyFrameBool nextFrame, double mix) {
18 | RiveCoreContext.setBool(object, propertyKey, value);
19 | }
20 |
21 | @override
22 | void valueChanged(bool from, bool to) {}
23 | }
24 |
--------------------------------------------------------------------------------
/lib/src/rive_core/backboard.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/backboard_base.dart';
3 | import 'package:rive/src/rive_core/assets/asset.dart';
4 |
5 | export 'package:rive/src/generated/backboard_base.dart';
6 |
7 | class Backboard extends BackboardBase {
8 | static final Backboard unknown = Backboard();
9 |
10 | final AssetList _assets = AssetList();
11 | AssetList get assets => _assets;
12 |
13 | bool internalAddAsset(Asset asset) {
14 | if (_assets.contains(asset)) {
15 | return false;
16 | }
17 | _assets.add(asset);
18 |
19 | return true;
20 | }
21 |
22 | bool internalRemoveAsset(Asset asset) {
23 | bool removed = _assets.remove(asset);
24 |
25 | return removed;
26 | }
27 |
28 | @override
29 | void onAdded() {}
30 |
31 | @override
32 | void onAddedDirty() {}
33 | }
34 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/triangle.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/shapes/triangle_base.dart';
2 | import 'package:rive/src/rive_core/shapes/path_vertex.dart';
3 | import 'package:rive/src/rive_core/shapes/straight_vertex.dart';
4 |
5 | /// Export the Base class for external use (e.g. rive.dart)
6 | export 'package:rive/src/generated/shapes/triangle_base.dart';
7 |
8 | class Triangle extends TriangleBase {
9 | @override
10 | List get vertices {
11 | double ox = -originX * width;
12 | double oy = -originY * height;
13 |
14 | return [
15 | StraightVertex.procedural()
16 | ..x = ox + width / 2
17 | ..y = oy,
18 | StraightVertex.procedural()
19 | ..x = ox + width
20 | ..y = oy + height,
21 | StraightVertex.procedural()
22 | ..x = ox
23 | ..y = oy + height
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/contour_mesh_vertex_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/shapes/contour_mesh_vertex_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/generated/container_component_base.dart';
7 | import 'package:rive/src/generated/shapes/vertex_base.dart';
8 | import 'package:rive/src/rive_core/shapes/mesh_vertex.dart';
9 |
10 | abstract class ContourMeshVertexBase extends MeshVertex {
11 | static const int typeKey = 111;
12 | @override
13 | int get coreType => ContourMeshVertexBase.typeKey;
14 | @override
15 | Set get coreTypes => {
16 | ContourMeshVertexBase.typeKey,
17 | MeshVertexBase.typeKey,
18 | VertexBase.typeKey,
19 | ContainerComponentBase.typeKey,
20 | ComponentBase.typeKey
21 | };
22 | }
23 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/nested_remap_animation.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/nested_remap_animation_base.dart';
2 | import 'package:rive/src/rive_core/animation/nested_linear_animation.dart';
3 |
4 | export 'package:rive/src/generated/animation/nested_remap_animation_base.dart';
5 |
6 | class NestedRemapAnimation extends NestedRemapAnimationBase {
7 | @override
8 | void timeChanged(double from, double to) => syncTime();
9 |
10 | void syncTime() {
11 | if (linearAnimationInstance != null) {
12 | linearAnimationInstance!
13 | .goto(linearAnimationInstance!.durationSeconds * time);
14 | }
15 | }
16 |
17 | @override
18 | void linearAnimationInstanceChanged(NestedLinearAnimationInstance? from,
19 | NestedLinearAnimationInstance? to) =>
20 | syncTime();
21 |
22 | @override
23 | bool get isEnabled => true;
24 | }
25 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/animation.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/animation/animation_base.dart';
3 | import 'package:rive/src/rive_core/artboard.dart';
4 |
5 | export 'package:rive/src/generated/animation/animation_base.dart';
6 |
7 | class Animation extends AnimationBase {
8 | Artboard? _artboard;
9 | Artboard? get artboard => _artboard;
10 | set artboard(Artboard? value) {
11 | if (_artboard == value) {
12 | return;
13 | }
14 | _artboard?.internalRemoveAnimation(this);
15 | _artboard = value;
16 | _artboard?.internalAddAnimation(this);
17 | }
18 |
19 | @override
20 | void onAddedDirty() {}
21 |
22 | @override
23 | void onAdded() {}
24 |
25 | @override
26 | bool validate() => super.validate() && _artboard != null;
27 |
28 | @override
29 | void nameChanged(String from, String to) {}
30 | }
31 |
--------------------------------------------------------------------------------
/lib/src/generated/bones/skeletal_component_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/bones/skeletal_component_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/generated/container_component_base.dart';
7 | import 'package:rive/src/generated/world_transform_component_base.dart';
8 | import 'package:rive/src/rive_core/transform_component.dart';
9 |
10 | abstract class SkeletalComponentBase extends TransformComponent {
11 | static const int typeKey = 39;
12 | @override
13 | int get coreType => SkeletalComponentBase.typeKey;
14 | @override
15 | Set get coreTypes => {
16 | SkeletalComponentBase.typeKey,
17 | TransformComponentBase.typeKey,
18 | WorldTransformComponentBase.typeKey,
19 | ContainerComponentBase.typeKey,
20 | ComponentBase.typeKey
21 | };
22 | }
23 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Web related
35 | lib/generated_plugin_registrant.dart
36 |
37 | # Symbolication related
38 | app.*.symbols
39 |
40 | # Obfuscation related
41 | app.*.map.json
42 |
43 | # Exceptions to above rules.
44 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
45 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/blend_state_direct_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/blend_state_direct_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/layer_state_base.dart';
6 | import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
7 | import 'package:rive/src/rive_core/animation/blend_animation_direct.dart';
8 | import 'package:rive/src/rive_core/animation/blend_state.dart';
9 |
10 | abstract class BlendStateDirectBase extends BlendState {
11 | static const int typeKey = 73;
12 | @override
13 | int get coreType => BlendStateDirectBase.typeKey;
14 | @override
15 | Set get coreTypes => {
16 | BlendStateDirectBase.typeKey,
17 | BlendStateBase.typeKey,
18 | LayerStateBase.typeKey,
19 | StateMachineLayerComponentBase.typeKey
20 | };
21 | }
22 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/cubic_vertex_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/shapes/cubic_vertex_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/generated/container_component_base.dart';
7 | import 'package:rive/src/generated/shapes/vertex_base.dart';
8 | import 'package:rive/src/rive_core/bones/cubic_weight.dart';
9 | import 'package:rive/src/rive_core/shapes/path_vertex.dart';
10 |
11 | abstract class CubicVertexBase extends PathVertex {
12 | static const int typeKey = 36;
13 | @override
14 | int get coreType => CubicVertexBase.typeKey;
15 | @override
16 | Set get coreTypes => {
17 | CubicVertexBase.typeKey,
18 | PathVertexBase.typeKey,
19 | VertexBase.typeKey,
20 | ContainerComponentBase.typeKey,
21 | ComponentBase.typeKey
22 | };
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/lib/src/rive_core/constraints/transform_component_constraint_y.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/constraints/transform_component_constraint_y_base.dart';
2 | export 'package:rive/src/generated/constraints/transform_component_constraint_y_base.dart';
3 |
4 | abstract class TransformComponentConstraintY
5 | extends TransformComponentConstraintYBase {
6 | @override
7 | void minValueYChanged(double from, double to) => markConstraintDirty();
8 |
9 | @override
10 | void maxValueYChanged(double from, double to) => markConstraintDirty();
11 |
12 | @override
13 | void copyFactorYChanged(double from, double to) => markConstraintDirty();
14 |
15 | @override
16 | void doesCopyYChanged(bool from, bool to) => markConstraintDirty();
17 |
18 | @override
19 | void maxYChanged(bool from, bool to) => markConstraintDirty();
20 |
21 | @override
22 | void minYChanged(bool from, bool to) => markConstraintDirty();
23 | }
24 |
--------------------------------------------------------------------------------
/lib/src/generated/constraints/transform_constraint_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/constraints/transform_constraint_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/generated/constraints/constraint_base.dart';
7 | import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
8 | import 'package:rive/src/rive_core/constraints/transform_space_constraint.dart';
9 |
10 | abstract class TransformConstraintBase extends TransformSpaceConstraint {
11 | static const int typeKey = 83;
12 | @override
13 | int get coreType => TransformConstraintBase.typeKey;
14 | @override
15 | Set get coreTypes => {
16 | TransformConstraintBase.typeKey,
17 | TransformSpaceConstraintBase.typeKey,
18 | TargetedConstraintBase.typeKey,
19 | ConstraintBase.typeKey,
20 | ComponentBase.typeKey
21 | };
22 | }
23 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/shape_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/shapes/shape_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/generated/component_base.dart';
5 | import 'package:rive/src/generated/container_component_base.dart';
6 | import 'package:rive/src/generated/node_base.dart';
7 | import 'package:rive/src/generated/transform_component_base.dart';
8 | import 'package:rive/src/generated/world_transform_component_base.dart';
9 | import 'package:rive/src/rive_core/drawable.dart';
10 |
11 | abstract class ShapeBase extends Drawable {
12 | static const int typeKey = 3;
13 | @override
14 | int get coreType => ShapeBase.typeKey;
15 | @override
16 | Set get coreTypes => {
17 | ShapeBase.typeKey,
18 | DrawableBase.typeKey,
19 | NodeBase.typeKey,
20 | TransformComponentBase.typeKey,
21 | WorldTransformComponentBase.typeKey,
22 | ContainerComponentBase.typeKey,
23 | ComponentBase.typeKey
24 | };
25 | }
26 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/event_bool_change.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/event_bool_change_base.dart';
2 | import 'package:rive/src/rive_core/state_machine_controller.dart';
3 |
4 | export 'package:rive/src/generated/animation/event_bool_change_base.dart';
5 |
6 | class EventBoolChange extends EventBoolChangeBase {
7 | @override
8 | void valueChanged(int from, int to) {}
9 |
10 | @override
11 | void perform(StateMachineController controller) {
12 | switch (value) {
13 | case 0:
14 | controller.setInputValue(inputId, false);
15 | break;
16 | case 1:
17 | controller.setInputValue(inputId, true);
18 | break;
19 | default:
20 | // Toggle
21 | dynamic existing = controller.getInputValue(inputId);
22 | if (existing is bool) {
23 | controller.setInputValue(inputId, !existing);
24 | } else {
25 | controller.setInputValue(inputId, true);
26 | }
27 |
28 | break;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/transition_bool_condition.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 |
3 | import 'package:rive/src/generated/animation/transition_bool_condition_base.dart';
4 | import 'package:rive/src/rive_core/animation/state_machine_bool.dart';
5 | import 'package:rive/src/rive_core/animation/transition_condition.dart';
6 |
7 | export 'package:rive/src/generated/animation/transition_bool_condition_base.dart';
8 |
9 | class TransitionBoolCondition extends TransitionBoolConditionBase {
10 | @override
11 | bool validate() => super.validate() && (input is StateMachineBool);
12 |
13 | @override
14 | bool evaluate(HashMap values) {
15 | if (input is! StateMachineBool) {
16 | return true;
17 | }
18 | var boolInput = input as StateMachineBool;
19 | dynamic providedValue = values[input.id];
20 | bool value = providedValue is bool ? providedValue : boolInput.value;
21 | return (value && op == TransitionConditionOp.equal) ||
22 | (!value && op == TransitionConditionOp.notEqual);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lib/src/rive_core/rive_animation_controller.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/foundation.dart';
2 |
3 | /// Abstraction for receiving a per frame callback while isPlaying is true to
4 | /// apply animation based on an elapsed amount of time.
5 | abstract class RiveAnimationController {
6 | final _isActive = ValueNotifier(false);
7 | ValueListenable get isActiveChanged => _isActive;
8 |
9 | bool get isActive => _isActive.value;
10 | set isActive(bool value) {
11 | if (_isActive.value != value) {
12 | _isActive.value = value;
13 | if (value) {
14 | onActivate();
15 | } else {
16 | onDeactivate();
17 | }
18 | }
19 | }
20 |
21 | @protected
22 | void onActivate() {}
23 | @protected
24 | void onDeactivate() {}
25 |
26 | /// Apply animation to objects registered in [core]. Note that a [core]
27 | /// context is specified as animations can be applied to instances.
28 | void apply(T core, double elapsedSeconds);
29 |
30 | bool init(T core) => true;
31 | void dispose() {}
32 | }
33 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/lib/src/rive_core/bones/skinnable.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/rive_core/bones/skin.dart';
2 | import 'package:rive/src/rive_core/component.dart';
3 |
4 | import 'package:rive/src/rive_core/shapes/vertex.dart';
5 |
6 | /// An abstraction to give a common interface to any container component that
7 | /// can contain a skin to bind bones to.
8 | abstract class Skinnable {
9 | // _skin is null when this object isn't connected to bones.
10 | Skin? _skin;
11 | Skin? get skin => _skin;
12 |
13 | void appendChild(Component child);
14 |
15 | // ignore: use_setters_to_change_properties
16 | void addSkin(Skin skin) {
17 | // Notify old skin/maybe support multiple skins in the future?
18 | _skin = skin;
19 |
20 | markSkinDirty();
21 | }
22 |
23 | void removeSkin(Skin skin) {
24 | if (_skin == skin) {
25 | _skin = null;
26 |
27 | markSkinDirty();
28 | }
29 | }
30 |
31 | void markSkinDirty();
32 | }
33 |
34 | abstract class SkinnableProvider {
35 | Skinnable? get skinnable;
36 | }
37 |
--------------------------------------------------------------------------------
/.github/scripts/release/.release-it.json:
--------------------------------------------------------------------------------
1 | {
2 | "git": {
3 | "requireCleanWorkingDir": false,
4 | "commitMessage": "chore: release v${version}",
5 | "tagName": "${version}"
6 | },
7 | "github": {
8 | "release": true,
9 | "releaseName": "${version}"
10 | },
11 | "npm": {
12 | "publish": false,
13 | "ignoreVersion": true
14 | },
15 | "plugins": {
16 | "@release-it/bumper": {
17 | "in": {
18 | "file": "../../../VERSION",
19 | "type": "text/plain"
20 | },
21 | "out": {
22 | "file": "../../../VERSION",
23 | "type": "text/plain"
24 | }
25 | }
26 | },
27 | "hooks": {
28 | "after:bump": [
29 | "npx auto-changelog -p --commit-limit false --template changelog.hbs --prepend -o ../../../CHANGELOG.md",
30 | "git add ../../../CHANGELOG.md",
31 | "git add ../../../VERSION",
32 | "git add ../../../pubspec.yaml"
33 | ]
34 | }
35 | }
--------------------------------------------------------------------------------
/lib/src/rive_core/world_transform_component.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/world_transform_component_base.dart';
2 | import 'package:rive/src/rive_core/component_dirt.dart';
3 | import 'package:rive/src/rive_core/math/mat2d.dart';
4 |
5 | export 'package:rive/src/generated/world_transform_component_base.dart';
6 |
7 | /// A Component with world transform.
8 | abstract class WorldTransformComponent extends WorldTransformComponentBase {
9 | final Mat2D worldTransform = Mat2D();
10 | double get childOpacity => opacity;
11 |
12 | void markWorldTransformDirty() =>
13 | addDirt(ComponentDirt.worldTransform, recurse: true);
14 |
15 | @override
16 | void opacityChanged(double from, double to) {
17 | markWorldTransformDirty();
18 | }
19 |
20 | /// Returns the world transform of the parent component. Returns the identity
21 | /// if there is no parent (the artboard should be the only case here).
22 | Mat2D get parentWorldTransform => parent is WorldTransformComponent
23 | ? (parent as WorldTransformComponent).worldTransform
24 | : Mat2D.identity;
25 | }
26 |
--------------------------------------------------------------------------------
/lib/src/core/importers/state_transition_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/core/importers/artboard_import_stack_object.dart';
3 | import 'package:rive/src/rive_core/animation/state_transition.dart';
4 | import 'package:rive/src/rive_core/animation/transition_condition.dart';
5 |
6 | class StateTransitionImporter extends ArtboardImportStackObject {
7 | final StateMachineImporter stateMachineImporter;
8 | final StateTransition transition;
9 | StateTransitionImporter(this.transition, this.stateMachineImporter);
10 |
11 | void addCondition(TransitionCondition condition) {
12 | transition.context.addObject(condition);
13 | transition.internalAddCondition(condition);
14 | }
15 |
16 | @override
17 | bool resolve() {
18 | var inputs = stateMachineImporter.machine.inputs;
19 | for (final condition in transition.conditions) {
20 | var inputIndex = condition.inputId;
21 | if (inputIndex >= 0 && inputIndex < inputs.length) {
22 | condition.inputId = inputs[inputIndex].id;
23 | }
24 | }
25 | return true;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/lib/src/generated/constraints/rotation_constraint_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/constraints/rotation_constraint_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/generated/constraints/constraint_base.dart';
7 | import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
8 | import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
9 | import 'package:rive/src/rive_core/constraints/transform_component_constraint.dart';
10 |
11 | abstract class RotationConstraintBase extends TransformComponentConstraint {
12 | static const int typeKey = 89;
13 | @override
14 | int get coreType => RotationConstraintBase.typeKey;
15 | @override
16 | Set get coreTypes => {
17 | RotationConstraintBase.typeKey,
18 | TransformComponentConstraintBase.typeKey,
19 | TransformSpaceConstraintBase.typeKey,
20 | TargetedConstraintBase.typeKey,
21 | ConstraintBase.typeKey,
22 | ComponentBase.typeKey
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/lib/src/rive_core/assets/file_asset_contents.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/assets/file_asset_contents_base.dart';
3 | import 'package:rive/src/rive_core/assets/file_asset.dart';
4 |
5 | export 'package:rive/src/generated/assets/file_asset_contents_base.dart';
6 |
7 | /// Stores the data of the bytes into an object that is always imported in
8 | /// context of a FileAsset.
9 | class FileAssetContents extends FileAssetContentsBase {
10 | @override
11 | void bytesChanged(List from, List to) {}
12 |
13 | @override
14 | void onAdded() {}
15 |
16 | @override
17 | void onAddedDirty() {}
18 |
19 | /// Never permanently added to core, so always invalidate.
20 | @override
21 | bool validate() => false;
22 |
23 | @override
24 | bool import(ImportStack stack) {
25 | var fileAssetImporter =
26 | stack.latest(FileAssetBase.typeKey);
27 | if (fileAssetImporter == null) {
28 | return false;
29 | }
30 | fileAssetImporter.loadContents(this);
31 |
32 | return super.import(stack);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/lib/src/rive_core/constraints/transform_space_constraint.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
2 | import 'package:rive/src/rive_core/math/transform_components.dart';
3 | import 'package:rive/src/rive_core/transform_space.dart';
4 |
5 | export 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
6 |
7 | abstract class TransformSpaceConstraint extends TransformSpaceConstraintBase {
8 | final TransformComponents componentsA = TransformComponents();
9 | final TransformComponents componentsB = TransformComponents();
10 |
11 | TransformSpace get destSpace => TransformSpace.values[destSpaceValue];
12 | set destSpace(TransformSpace value) => destSpaceValue = value.index;
13 |
14 | TransformSpace get sourceSpace => TransformSpace.values[sourceSpaceValue];
15 | set sourceSpace(TransformSpace value) => sourceSpaceValue = value.index;
16 |
17 | @override
18 | void destSpaceValueChanged(int from, int to) => markConstraintDirty();
19 |
20 | @override
21 | void sourceSpaceValueChanged(int from, int to) => markConstraintDirty();
22 | }
23 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/animation_state_instance.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/rive_core/animation/animation_state.dart';
3 | import 'package:rive/src/rive_core/animation/linear_animation_instance.dart';
4 | import 'package:rive/src/rive_core/animation/state_instance.dart';
5 |
6 | /// Simple wrapper around [LinearAnimationInstance] making it compatible with
7 | /// the [StateMachine]'s [StateInstance] interface.
8 | class AnimationStateInstance extends StateInstance {
9 | final LinearAnimationInstance animationInstance;
10 |
11 | AnimationStateInstance(AnimationState state)
12 | : assert(state.animation != null),
13 | animationInstance = LinearAnimationInstance(state.animation!),
14 | super(state);
15 |
16 | @override
17 | void advance(double seconds, _) => animationInstance.advance(seconds);
18 |
19 | @override
20 | void apply(CoreContext core, double mix) => animationInstance.animation
21 | .apply(animationInstance.time, coreContext: core, mix: mix);
22 |
23 | @override
24 | bool get keepGoing => animationInstance.keepGoing;
25 | }
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Rive
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/nested_simple_animation.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/nested_simple_animation_base.dart';
2 | import 'package:rive/src/rive_core/animation/nested_linear_animation.dart';
3 | import 'package:rive/src/rive_core/nested_artboard.dart';
4 |
5 | export 'package:rive/src/generated/animation/nested_simple_animation_base.dart';
6 |
7 | class NestedSimpleAnimation extends NestedSimpleAnimationBase {
8 | @override
9 | void isPlayingChanged(bool from, bool to) {}
10 |
11 | @override
12 | void speedChanged(double from, double to) {
13 | linearAnimationInstance?.speed = to;
14 | }
15 |
16 | @override
17 | void linearAnimationInstanceChanged(
18 | NestedLinearAnimationInstance? from, NestedLinearAnimationInstance? to) {
19 | to?.speed = speed;
20 | }
21 |
22 | @override
23 | bool get isEnabled => true;
24 |
25 | @override
26 | void advance(double elapsedSeconds, MountedArtboard mountedArtboard) {
27 | if (isPlaying) {
28 | linearAnimationInstance?.advance(elapsedSeconds);
29 | }
30 | super.advance(elapsedSeconds, mountedArtboard);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yaml:
--------------------------------------------------------------------------------
1 | name: Publish to pub.dev
2 |
3 | on:
4 | pull_request:
5 | types: [closed]
6 | branches:
7 | - master
8 | jobs:
9 | merge_job:
10 | runs-on: ubuntu-latest
11 | if: github.event.pull_request.merged == true
12 | steps:
13 | - uses: actions/checkout@v2
14 | with:
15 | submodules: true
16 | - uses: actions/setup-node@v2
17 | with:
18 | node-version: "12.x"
19 | registry-url: "https://registry.npmjs.org"
20 | - uses: subosito/flutter-action@v1
21 | with:
22 | channel: "stable"
23 | - name: Install dependencies
24 | run: npm ci
25 | working-directory: ./.github/scripts/release
26 | - name: Git config
27 | run: |
28 | git config --local user.email 'hello@rive.app'
29 | git config --local user.name ${{ github.actor }}
30 | - name: Release
31 | run: ./release.sh
32 | working-directory: ./.github/scripts/release
33 | env:
34 | GITHUB_AUTHOR: ${{ github.actor }}
35 | GITHUB_TOKEN: ${{ secrets.RIVE_REPO_PAT }}
36 |
--------------------------------------------------------------------------------
/lib/src/core/importers/file_asset_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/rive_core/assets/file_asset.dart';
3 | import 'package:rive/src/rive_core/assets/file_asset_contents.dart';
4 |
5 | /// A helper for resolving Rive file assets (like images) that are provided out
6 | /// of band with regards to the .riv file itself.
7 | // ignore: one_member_abstracts
8 | abstract class FileAssetResolver {
9 | Future loadContents(FileAsset asset);
10 | }
11 |
12 | class FileAssetImporter extends ImportStackObject {
13 | final FileAssetResolver? assetResolver;
14 | final FileAsset fileAsset;
15 |
16 | FileAssetImporter(this.fileAsset, this.assetResolver);
17 |
18 | bool _loadedContents = false;
19 |
20 | void loadContents(FileAssetContents contents) {
21 | _loadedContents = true;
22 | fileAsset.decode(contents.bytes);
23 | }
24 |
25 | @override
26 | bool resolve() {
27 | if (!_loadedContents) {
28 | // try to get them out of band
29 | assetResolver?.loadContents(fileAsset).then(fileAsset.decode);
30 | }
31 | return super.resolve();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/blend_state_direct_instance.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/rive_core/animation/blend_animation_direct.dart';
2 | import 'package:rive/src/rive_core/animation/blend_state_direct.dart';
3 | import 'package:rive/src/rive_core/animation/blend_state_instance.dart';
4 | import 'package:rive/src/rive_core/state_machine_controller.dart';
5 |
6 | /// [BlendStateDirect] mixing logic that runs inside the [StateMachine].
7 | class BlendStateDirectInstance
8 | extends BlendStateInstance {
9 | BlendStateDirectInstance(BlendStateDirect state) : super(state);
10 |
11 | @override
12 | void advance(double seconds, StateMachineController controller) {
13 | super.advance(seconds, controller);
14 | for (final animation in animationInstances) {
15 | dynamic inputValue =
16 | controller.getInputValue(animation.blendAnimation.inputId);
17 | var value = (inputValue is double
18 | ? inputValue
19 | : animation.blendAnimation.input?.value) ??
20 | 0;
21 | animation.mix = (value / 100).clamp(0, 1);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/ellipse_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/shapes/ellipse_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/generated/component_base.dart';
5 | import 'package:rive/src/generated/container_component_base.dart';
6 | import 'package:rive/src/generated/node_base.dart';
7 | import 'package:rive/src/generated/shapes/path_base.dart';
8 | import 'package:rive/src/generated/transform_component_base.dart';
9 | import 'package:rive/src/generated/world_transform_component_base.dart';
10 | import 'package:rive/src/rive_core/shapes/parametric_path.dart';
11 |
12 | abstract class EllipseBase extends ParametricPath {
13 | static const int typeKey = 4;
14 | @override
15 | int get coreType => EllipseBase.typeKey;
16 | @override
17 | Set get coreTypes => {
18 | EllipseBase.typeKey,
19 | ParametricPathBase.typeKey,
20 | PathBase.typeKey,
21 | NodeBase.typeKey,
22 | TransformComponentBase.typeKey,
23 | WorldTransformComponentBase.typeKey,
24 | ContainerComponentBase.typeKey,
25 | ComponentBase.typeKey
26 | };
27 | }
28 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/triangle_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/shapes/triangle_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/generated/component_base.dart';
5 | import 'package:rive/src/generated/container_component_base.dart';
6 | import 'package:rive/src/generated/node_base.dart';
7 | import 'package:rive/src/generated/shapes/path_base.dart';
8 | import 'package:rive/src/generated/transform_component_base.dart';
9 | import 'package:rive/src/generated/world_transform_component_base.dart';
10 | import 'package:rive/src/rive_core/shapes/parametric_path.dart';
11 |
12 | abstract class TriangleBase extends ParametricPath {
13 | static const int typeKey = 8;
14 | @override
15 | int get coreType => TriangleBase.typeKey;
16 | @override
17 | Set get coreTypes => {
18 | TriangleBase.typeKey,
19 | ParametricPathBase.typeKey,
20 | PathBase.typeKey,
21 | NodeBase.typeKey,
22 | TransformComponentBase.typeKey,
23 | WorldTransformComponentBase.typeKey,
24 | ContainerComponentBase.typeKey,
25 | ComponentBase.typeKey
26 | };
27 | }
28 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/blend_animation_direct.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/animation/blend_animation_direct_base.dart';
3 | import 'package:rive/src/rive_core/animation/state_machine.dart';
4 | import 'package:rive/src/rive_core/animation/state_machine_number.dart';
5 |
6 | export 'package:rive/src/generated/animation/blend_animation_direct_base.dart';
7 |
8 | class BlendAnimationDirect extends BlendAnimationDirectBase {
9 | StateMachineNumber? _input;
10 | StateMachineNumber? get input => _input;
11 |
12 | @override
13 | void inputIdChanged(int from, int to) {}
14 |
15 | @override
16 | bool import(ImportStack stack) {
17 | var importer = stack.latest(StateMachineBase.typeKey);
18 | if (importer == null) {
19 | return false;
20 | }
21 | if (inputId >= 0 && inputId < importer.machine.inputs.length) {
22 | var found = importer.machine.inputs[inputId];
23 | if (found is StateMachineNumber) {
24 | _input = found;
25 | inputId = found.id;
26 | }
27 | }
28 |
29 | return super.import(stack);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/test/rive_file_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_test/flutter_test.dart';
2 | import 'package:rive/rive.dart';
3 |
4 | import 'src/utils.dart';
5 |
6 | void main() {
7 | late RiveFile riveFile;
8 |
9 | setUp(() {
10 | final riveBytes = loadFile('assets/rive-flutter-test-asset.riv');
11 | riveFile = RiveFile.import(riveBytes);
12 | });
13 |
14 | test('Rive files contain the correct number of artboards', () {
15 | expect(riveFile.artboards.length, 2);
16 | });
17 |
18 | test('A default artboard is available in a Rive file', () {
19 | // Create a dummy RiveFile
20 | expect(riveFile.mainArtboard, isNotNull);
21 | expect(riveFile.mainArtboard.name, 'Artboard 1');
22 | });
23 |
24 | test('Artboards can be retrieved by name', () {
25 | var artboard = riveFile.artboardByName('Artboard 1');
26 | expect(artboard, isNotNull);
27 | expect(artboard!.name, 'Artboard 1');
28 |
29 | artboard = riveFile.artboardByName('Artboard 2');
30 | expect(artboard, isNotNull);
31 | expect(artboard!.name, 'Artboard 2');
32 |
33 | artboard = riveFile.artboardByName('Nonexistant');
34 | expect(artboard, isNull);
35 | });
36 | }
37 |
--------------------------------------------------------------------------------
/example/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/lib/src/rive_core/assets/image_asset.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:typed_data';
3 | import 'dart:ui' as ui;
4 |
5 | import 'package:flutter/foundation.dart';
6 | import 'package:rive/src/generated/assets/image_asset_base.dart';
7 | import 'package:rive/src/rive_core/shapes/image.dart';
8 |
9 | export 'package:rive/src/generated/assets/image_asset_base.dart';
10 |
11 | class ImageAsset extends ImageAssetBase {
12 | ui.Image? _image;
13 | ui.Image? get image => _image;
14 |
15 | ImageAsset();
16 |
17 | @visibleForTesting
18 | ImageAsset.fromTestImage(this._image);
19 |
20 | @visibleForTesting
21 | set image(ui.Image? image) {
22 | _image = image;
23 | }
24 |
25 | @override
26 | Future decode(Uint8List bytes) {
27 | final completer = Completer();
28 | ui.decodeImageFromList(bytes, (value) {
29 | _image = value;
30 | completer.complete();
31 | });
32 | return completer.future;
33 | }
34 |
35 | Image getDefaultObject() => Image()
36 | ..asset = this
37 | ..name = name;
38 |
39 | /// The editor works with images as PNGs, even if their sources may have come
40 | /// from other formats.
41 | @override
42 | String get fileExtension => 'png';
43 | }
44 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/cubic_vertex.dart:
--------------------------------------------------------------------------------
1 | import 'dart:typed_data';
2 |
3 | import 'package:rive/src/generated/shapes/cubic_vertex_base.dart';
4 | import 'package:rive/src/rive_core/bones/weight.dart';
5 | import 'package:rive/src/rive_core/math/mat2d.dart';
6 | import 'package:rive/src/rive_core/math/vec2d.dart';
7 |
8 | export 'package:rive/src/generated/shapes/cubic_vertex_base.dart';
9 |
10 | abstract class CubicVertex extends CubicVertexBase {
11 | Vec2D get outPoint;
12 | Vec2D get inPoint;
13 |
14 | set outPoint(Vec2D value);
15 | set inPoint(Vec2D value);
16 |
17 | @override
18 | Vec2D get renderTranslation => weight?.translation ?? super.renderTranslation;
19 |
20 | Vec2D get renderIn => weight?.inTranslation ?? inPoint;
21 | Vec2D get renderOut => weight?.outTranslation ?? outPoint;
22 |
23 | @override
24 | void deform(Mat2D world, Float32List boneTransforms) {
25 | super.deform(world, boneTransforms);
26 |
27 | Weight.deform(outPoint.x, outPoint.y, weight!.outIndices, weight!.outValues,
28 | world, boneTransforms, weight!.outTranslation);
29 | Weight.deform(inPoint.x, inPoint.y, weight!.inIndices, weight!.inValues,
30 | world, boneTransforms, weight!.inTranslation);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/lib/src/generated/constraints/scale_constraint_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/constraints/scale_constraint_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/generated/constraints/constraint_base.dart';
7 | import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
8 | import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
9 | import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
10 | import 'package:rive/src/rive_core/constraints/transform_component_constraint_y.dart';
11 |
12 | abstract class ScaleConstraintBase extends TransformComponentConstraintY {
13 | static const int typeKey = 88;
14 | @override
15 | int get coreType => ScaleConstraintBase.typeKey;
16 | @override
17 | Set get coreTypes => {
18 | ScaleConstraintBase.typeKey,
19 | TransformComponentConstraintYBase.typeKey,
20 | TransformComponentConstraintBase.typeKey,
21 | TransformSpaceConstraintBase.typeKey,
22 | TargetedConstraintBase.typeKey,
23 | ConstraintBase.typeKey,
24 | ComponentBase.typeKey
25 | };
26 | }
27 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/state_machine.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/animation/state_machine_base.dart';
3 | import 'package:rive/src/rive_core/animation/state_machine_event.dart';
4 | import 'package:rive/src/rive_core/animation/state_machine_input.dart';
5 | import 'package:rive/src/rive_core/animation/state_machine_layer.dart';
6 | import 'package:rive/src/rive_core/artboard.dart';
7 |
8 | export 'package:rive/src/generated/animation/state_machine_base.dart';
9 |
10 | class StateMachine extends StateMachineBase {
11 | final StateMachineComponents inputs =
12 | StateMachineComponents();
13 | final StateMachineComponents layers =
14 | StateMachineComponents();
15 | final StateMachineComponents events =
16 | StateMachineComponents();
17 |
18 | @override
19 | bool import(ImportStack stack) {
20 | var artboardImporter = stack.latest(ArtboardBase.typeKey);
21 | if (artboardImporter == null) {
22 | return false;
23 | }
24 | artboardImporter.addStateMachine(this);
25 |
26 | return super.import(stack);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/src/rive_core/constraints/targeted_constraint.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
2 | import 'package:rive/src/rive_core/transform_component.dart';
3 | export 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
4 |
5 | /// A [Constraint] which uses an external target to help influence the computed
6 | /// transform.
7 | abstract class TargetedConstraint extends TargetedConstraintBase {
8 | TransformComponent? _target;
9 | TransformComponent? get target => _target;
10 | set target(TransformComponent? value) {
11 | if (_target == value) {
12 | return;
13 | }
14 |
15 | _target = value;
16 | }
17 |
18 | @override
19 | void targetIdChanged(int from, int to) => target = context.resolve(to);
20 |
21 | @override
22 | void buildDependencies() {
23 | super.buildDependencies();
24 | // Targeted constraints must have their constrainedComponent update after
25 | // the target.
26 | if (constrainedComponent != null) {
27 | _target?.addDependent(constrainedComponent!, via: this);
28 | }
29 | }
30 |
31 | @override
32 | void onAddedDirty() {
33 | super.onAddedDirty();
34 | target = context.resolve(targetId);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/example/lib/simple_state_machine.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:rive/rive.dart';
3 |
4 | class SimpleStateMachine extends StatefulWidget {
5 | const SimpleStateMachine({Key? key}) : super(key: key);
6 |
7 | @override
8 | _SimpleStateMachineState createState() => _SimpleStateMachineState();
9 | }
10 |
11 | class _SimpleStateMachineState extends State {
12 | SMITrigger? _bump;
13 |
14 | void _onRiveInit(Artboard artboard) {
15 | final controller = StateMachineController.fromArtboard(artboard, 'bumpy');
16 | artboard.addController(controller!);
17 | _bump = controller.findInput('bump') as SMITrigger;
18 | }
19 |
20 | void _hitBump() => _bump?.fire();
21 |
22 | @override
23 | Widget build(BuildContext context) {
24 | return Scaffold(
25 | appBar: AppBar(
26 | title: const Text('Simple Animation'),
27 | ),
28 | body: Center(
29 | child: GestureDetector(
30 | child: RiveAnimation.network(
31 | 'https://cdn.rive.app/animations/vehicles.riv',
32 | fit: BoxFit.cover,
33 | onInit: _onRiveInit,
34 | ),
35 | onTap: _hitBump,
36 | ),
37 | ),
38 | );
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/polygon.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math';
2 |
3 | import 'package:rive/src/generated/shapes/polygon_base.dart';
4 | import 'package:rive/src/rive_core/bones/weight.dart';
5 | import 'package:rive/src/rive_core/shapes/path_vertex.dart';
6 | import 'package:rive/src/rive_core/shapes/straight_vertex.dart';
7 |
8 | export 'package:rive/src/generated/shapes/polygon_base.dart';
9 |
10 | class Polygon extends PolygonBase {
11 | @override
12 | void cornerRadiusChanged(double from, double to) => markPathDirty();
13 |
14 | @override
15 | void pointsChanged(int from, int to) => markPathDirty();
16 |
17 | @override
18 | List> get vertices {
19 | double ox = -originX * width + width / 2;
20 | double oy = -originY * height + height / 2;
21 | var vertexList = >[];
22 | var halfWidth = width / 2;
23 | var halfHeight = height / 2;
24 | var angle = -pi / 2;
25 | var inc = 2 * pi / points;
26 | for (int i = 0; i < points; i++) {
27 | vertexList.add(StraightVertex.procedural()
28 | ..x = ox + cos(angle) * halfWidth
29 | ..y = oy + sin(angle) * halfHeight
30 | ..radius = cornerRadius);
31 | angle += inc;
32 | }
33 | return vertexList;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/state_instance.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/rive_core/animation/layer_state.dart';
3 | import 'package:rive/src/rive_core/state_machine_controller.dart';
4 |
5 | /// Represents the instance of a [LayerState] which is being used in a
6 | /// [LayerController] of a [StateMachineController]. Abstract representation of
7 | /// an Animation (for [AnimationState]) or set of Animations in the case of a
8 | /// [BlendState].
9 | abstract class StateInstance {
10 | final LayerState state;
11 |
12 | StateInstance(this.state);
13 |
14 | void advance(double seconds, StateMachineController controller);
15 | void apply(CoreContext core, double mix);
16 |
17 | bool get keepGoing;
18 |
19 | void dispose() {}
20 | }
21 |
22 | /// A single one of these is created per Layer which just represents/wraps the
23 | /// AnyState but conforms to the instance interface.
24 | class SystemStateInstance extends StateInstance {
25 | SystemStateInstance(LayerState state) : super(state);
26 | @override
27 | void advance(double seconds, StateMachineController controller) {}
28 |
29 | @override
30 | void apply(CoreContext core, double mix) {}
31 |
32 | @override
33 | bool get keepGoing => false;
34 | }
35 |
--------------------------------------------------------------------------------
/example/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | rive_example
18 |
19 |
20 |
21 |
24 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/lib/src/generated/assets/asset_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/assets/asset_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/core/core.dart';
5 |
6 | abstract class AssetBase extends Core {
7 | static const int typeKey = 99;
8 | @override
9 | int get coreType => AssetBase.typeKey;
10 | @override
11 | Set get coreTypes => {AssetBase.typeKey};
12 |
13 | /// --------------------------------------------------------------------------
14 | /// Name field with key 203.
15 | static const String nameInitialValue = '';
16 | String _name = nameInitialValue;
17 | static const int namePropertyKey = 203;
18 |
19 | /// Name of the asset
20 | String get name => _name;
21 |
22 | /// Change the [_name] field value.
23 | /// [nameChanged] will be invoked only if the field's value has changed.
24 | set name(String value) {
25 | if (_name == value) {
26 | return;
27 | }
28 | String from = _name;
29 | _name = value;
30 | if (hasValidated) {
31 | nameChanged(from, value);
32 | }
33 | }
34 |
35 | void nameChanged(String from, String to);
36 |
37 | @override
38 | void copy(covariant AssetBase source) {
39 | _name = source._name;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/generated/constraints/translation_constraint_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/constraints/translation_constraint_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/generated/constraints/constraint_base.dart';
7 | import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
8 | import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
9 | import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
10 | import 'package:rive/src/rive_core/constraints/transform_component_constraint_y.dart';
11 |
12 | abstract class TranslationConstraintBase extends TransformComponentConstraintY {
13 | static const int typeKey = 87;
14 | @override
15 | int get coreType => TranslationConstraintBase.typeKey;
16 | @override
17 | Set get coreTypes => {
18 | TranslationConstraintBase.typeKey,
19 | TransformComponentConstraintYBase.typeKey,
20 | TransformComponentConstraintBase.typeKey,
21 | TransformSpaceConstraintBase.typeKey,
22 | TargetedConstraintBase.typeKey,
23 | ConstraintBase.typeKey,
24 | ComponentBase.typeKey
25 | };
26 | }
27 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/paint/gradient_stop.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui' as ui;
2 |
3 | import 'package:rive/src/generated/shapes/paint/gradient_stop_base.dart';
4 | import 'package:rive/src/rive_core/container_component.dart';
5 | import 'package:rive/src/rive_core/shapes/paint/linear_gradient.dart';
6 |
7 | export 'package:rive/src/generated/shapes/paint/gradient_stop_base.dart';
8 |
9 | class GradientStop extends GradientStopBase {
10 | LinearGradient? _gradient;
11 | LinearGradient? get gradient => _gradient;
12 | ui.Color get color => ui.Color(colorValue);
13 | set color(ui.Color c) {
14 | colorValue = c.value;
15 | }
16 |
17 | @override
18 | void positionChanged(double from, double to) {
19 | _gradient?.markStopsDirty();
20 | }
21 |
22 | @override
23 | void colorValueChanged(int from, int to) {
24 | _gradient?.markGradientDirty();
25 | }
26 |
27 | @override
28 | void update(int dirt) {}
29 |
30 | @override
31 | bool validate() => super.validate() && _gradient != null;
32 |
33 | @override
34 | void parentChanged(ContainerComponent? from, ContainerComponent? to) {
35 | super.parentChanged(from, to);
36 | if (parent is LinearGradient) {
37 | _gradient = parent as LinearGradient;
38 | } else {
39 | _gradient = null;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/paint/shape_paint_mutator.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:rive/src/rive_core/artboard.dart';
3 | import 'package:rive/src/rive_core/shapes/shape_paint_container.dart';
4 |
5 | abstract class ShapePaintMutator {
6 | ShapePaintContainer? _shapePaintContainer;
7 | Paint _paint = Paint();
8 |
9 | /// Getter for the component's artboard
10 | Artboard? get artboard;
11 |
12 | /// The container is usually either a Shape or an Artboard, basically any of
13 | /// the various ContainerComponents that can contain Fills or Strokes.
14 | ShapePaintContainer? get shapePaintContainer => _shapePaintContainer;
15 | Paint get paint => _paint;
16 |
17 | double _renderOpacity = 1;
18 | double get renderOpacity => _renderOpacity;
19 | set renderOpacity(double value) {
20 | if (_renderOpacity != value) {
21 | _renderOpacity = value;
22 | syncColor();
23 | }
24 | }
25 |
26 | @mustCallSuper
27 | void syncColor() => _paint.isAntiAlias = artboard?.antialiasing ?? true;
28 |
29 | @mustCallSuper
30 | void initializePaintMutator(ShapePaintContainer container, Paint paint) {
31 | _shapePaintContainer = container;
32 | _paint = paint;
33 | _shapePaintContainer?.onPaintMutatorChanged(this);
34 | syncColor();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/animation_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/animation_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/core/core.dart';
6 |
7 | abstract class AnimationBase extends Core {
8 | static const int typeKey = 27;
9 | @override
10 | int get coreType => AnimationBase.typeKey;
11 | @override
12 | Set get coreTypes => {AnimationBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// Name field with key 55.
16 | static const String nameInitialValue = '';
17 | String _name = nameInitialValue;
18 | static const int namePropertyKey = 55;
19 |
20 | /// Name of the animation.
21 | String get name => _name;
22 |
23 | /// Change the [_name] field value.
24 | /// [nameChanged] will be invoked only if the field's value has changed.
25 | set name(String value) {
26 | if (_name == value) {
27 | return;
28 | }
29 | String from = _name;
30 | _name = value;
31 | if (hasValidated) {
32 | nameChanged(from, value);
33 | }
34 | }
35 |
36 | void nameChanged(String from, String to);
37 |
38 | @override
39 | void copy(covariant AnimationBase source) {
40 | _name = source._name;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/keyframe_double.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/animation/keyframe_double_base.dart';
3 | export 'package:rive/src/generated/animation/keyframe_double_base.dart';
4 |
5 | void _apply(
6 | Core object, int propertyKey, double mix, double value) {
7 | if (mix == 1) {
8 | RiveCoreContext.setDouble(object, propertyKey, value);
9 | } else {
10 | var mixi = 1.0 - mix;
11 | RiveCoreContext.setDouble(object, propertyKey,
12 | RiveCoreContext.getDouble(object, propertyKey) * mixi + value * mix);
13 | }
14 | }
15 |
16 | class KeyFrameDouble extends KeyFrameDoubleBase {
17 | @override
18 | void apply(Core object, int propertyKey, double mix) =>
19 | _apply(object, propertyKey, mix, value);
20 |
21 | @override
22 | void applyInterpolation(Core object, int propertyKey,
23 | double currentTime, KeyFrameDouble nextFrame, double mix) {
24 | var f = (currentTime - seconds) / (nextFrame.seconds - seconds);
25 |
26 | if (interpolator != null) {
27 | f = interpolator!.transform(f);
28 | }
29 |
30 | _apply(object, propertyKey, mix, value + (nextFrame.value - value) * f);
31 | }
32 |
33 | @override
34 | void valueChanged(double from, double to) {}
35 | }
36 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/paint/fill.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | import 'package:rive/src/generated/shapes/paint/fill_base.dart';
4 | import 'package:rive/src/rive_core/component_dirt.dart';
5 | import 'package:rive/src/rive_core/shapes/shape_paint_container.dart';
6 |
7 | export 'package:rive/src/generated/shapes/paint/fill_base.dart';
8 |
9 | /// A fill Shape painter.
10 | class Fill extends FillBase {
11 | @override
12 | Paint makePaint() => Paint()..style = PaintingStyle.fill;
13 |
14 | PathFillType get fillType => PathFillType.values[fillRule];
15 | set fillType(PathFillType type) => fillRule = type.index;
16 |
17 | @override
18 | void fillRuleChanged(int from, int to) =>
19 | parent?.addDirt(ComponentDirt.paint);
20 |
21 | @override
22 | void update(int dirt) {
23 | // Intentionally empty, fill doesn't update.
24 | // Because Fill never adds dependencies, it'll also never get called.
25 | }
26 |
27 | @override
28 | void onAdded() {
29 | super.onAdded();
30 | if (parent is ShapePaintContainer) {
31 | (parent as ShapePaintContainer).addFill(this);
32 | }
33 | }
34 |
35 | @override
36 | void draw(Canvas canvas, Path path) {
37 | if (!isVisible) {
38 | return;
39 | }
40 | path.fillType = fillType;
41 | canvas.drawPath(path, paint);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/keyframe_id_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/keyframe_id_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/keyframe.dart';
6 |
7 | abstract class KeyFrameIdBase extends KeyFrame {
8 | static const int typeKey = 50;
9 | @override
10 | int get coreType => KeyFrameIdBase.typeKey;
11 | @override
12 | Set get coreTypes => {KeyFrameIdBase.typeKey, KeyFrameBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// Value field with key 122.
16 | static const int valueInitialValue = -1;
17 | int _value = valueInitialValue;
18 | static const int valuePropertyKey = 122;
19 | int get value => _value;
20 |
21 | /// Change the [_value] field value.
22 | /// [valueChanged] will be invoked only if the field's value has changed.
23 | set value(int value) {
24 | if (_value == value) {
25 | return;
26 | }
27 | int from = _value;
28 | _value = value;
29 | if (hasValidated) {
30 | valueChanged(from, value);
31 | }
32 | }
33 |
34 | void valueChanged(int from, int to);
35 |
36 | @override
37 | void copy(covariant KeyFrameIdBase source) {
38 | super.copy(source);
39 | _value = source._value;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/rive_core/constraints/transform_component_constraint.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
2 | import 'package:rive/src/rive_core/transform_space.dart';
3 | export 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
4 |
5 | abstract class TransformComponentConstraint
6 | extends TransformComponentConstraintBase {
7 | TransformSpace get minMaxSpace => TransformSpace.values[minMaxSpaceValue];
8 | set minMaxSpace(TransformSpace value) => minMaxSpaceValue = value.index;
9 |
10 | @override
11 | void minMaxSpaceValueChanged(int from, int to) => markConstraintDirty();
12 |
13 | @override
14 | void minValueChanged(double from, double to) => markConstraintDirty();
15 |
16 | @override
17 | void maxValueChanged(double from, double to) => markConstraintDirty();
18 |
19 | @override
20 | void copyFactorChanged(double from, double to) => markConstraintDirty();
21 |
22 | @override
23 | void doesCopyChanged(bool from, bool to) => markConstraintDirty();
24 |
25 | @override
26 | void maxChanged(bool from, bool to) => markConstraintDirty();
27 |
28 | @override
29 | void minChanged(bool from, bool to) => markConstraintDirty();
30 |
31 | @override
32 | void offsetChanged(bool from, bool to) => markConstraintDirty();
33 | }
34 |
--------------------------------------------------------------------------------
/lib/src/extensions.dart:
--------------------------------------------------------------------------------
1 | /// Extensions to the runtime core classes
2 | import 'package:collection/collection.dart';
3 | import 'package:rive/src/controllers/state_machine_controller.dart';
4 | import 'package:rive/src/rive_core/animation/linear_animation.dart';
5 | import 'package:rive/src/rive_core/animation/linear_animation_instance.dart';
6 | import 'package:rive/src/rive_core/artboard.dart';
7 | import 'package:rive/src/rive_core/state_machine_controller.dart' as core;
8 |
9 | /// Artboard extensions
10 | extension ArtboardAdditions on Artboard {
11 | /// Returns an animation with the given name, or null if no animation with
12 | /// that name exists in the artboard
13 | LinearAnimationInstance? animationByName(String name) {
14 | final animation = animations.firstWhereOrNull(
15 | (animation) => animation is LinearAnimation && animation.name == name);
16 | if (animation != null) {
17 | return LinearAnimationInstance(animation as LinearAnimation);
18 | }
19 | return null;
20 | }
21 |
22 | /// Returns a StateMachine with the given name, or null if no state machine
23 | /// with that name exists in the artboard
24 | StateMachineController? stateMachineByName(String name,
25 | {core.OnStateChange? onChange}) =>
26 | StateMachineController.fromArtboard(this, name, onStateChange: onChange);
27 | }
28 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/keyframe_color_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/keyframe_color_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/keyframe.dart';
6 |
7 | abstract class KeyFrameColorBase extends KeyFrame {
8 | static const int typeKey = 37;
9 | @override
10 | int get coreType => KeyFrameColorBase.typeKey;
11 | @override
12 | Set get coreTypes => {KeyFrameColorBase.typeKey, KeyFrameBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// Value field with key 88.
16 | static const int valueInitialValue = 0;
17 | int _value = valueInitialValue;
18 | static const int valuePropertyKey = 88;
19 | int get value => _value;
20 |
21 | /// Change the [_value] field value.
22 | /// [valueChanged] will be invoked only if the field's value has changed.
23 | set value(int value) {
24 | if (_value == value) {
25 | return;
26 | }
27 | int from = _value;
28 | _value = value;
29 | if (hasValidated) {
30 | valueChanged(from, value);
31 | }
32 | }
33 |
34 | void valueChanged(int from, int to);
35 |
36 | @override
37 | void copy(covariant KeyFrameColorBase source) {
38 | super.copy(source);
39 | _value = source._value;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/keyframe_bool_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/keyframe_bool_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/keyframe.dart';
6 |
7 | abstract class KeyFrameBoolBase extends KeyFrame {
8 | static const int typeKey = 84;
9 | @override
10 | int get coreType => KeyFrameBoolBase.typeKey;
11 | @override
12 | Set get coreTypes => {KeyFrameBoolBase.typeKey, KeyFrameBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// Value field with key 181.
16 | static const bool valueInitialValue = false;
17 | bool _value = valueInitialValue;
18 | static const int valuePropertyKey = 181;
19 | bool get value => _value;
20 |
21 | /// Change the [_value] field value.
22 | /// [valueChanged] will be invoked only if the field's value has changed.
23 | set value(bool value) {
24 | if (_value == value) {
25 | return;
26 | }
27 | bool from = _value;
28 | _value = value;
29 | if (hasValidated) {
30 | valueChanged(from, value);
31 | }
32 | }
33 |
34 | void valueChanged(bool from, bool to);
35 |
36 | @override
37 | void copy(covariant KeyFrameBoolBase source) {
38 | super.copy(source);
39 | _value = source._value;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/rive_core/draw_target.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/draw_target_base.dart';
3 | import 'package:rive/src/rive_core/drawable.dart';
4 |
5 | export 'package:rive/src/generated/draw_target_base.dart';
6 |
7 | enum DrawTargetPlacement { before, after }
8 |
9 | class DrawTarget extends DrawTargetBase {
10 | // Store first and last drawables that are affected by this target.
11 | Drawable? first;
12 | Drawable? last;
13 |
14 | Drawable? _drawable;
15 | Drawable? get drawable => _drawable;
16 | set drawable(Drawable? value) {
17 | if (_drawable == value) {
18 | return;
19 | }
20 |
21 | _drawable = value;
22 | drawableId = value?.id ?? Core.missingId;
23 | }
24 |
25 | DrawTargetPlacement get placement =>
26 | DrawTargetPlacement.values[placementValue];
27 | set placement(DrawTargetPlacement value) => placementValue = value.index;
28 |
29 | @override
30 | void drawableIdChanged(int from, int to) {
31 | drawable = context.resolve(to);
32 | }
33 |
34 | @override
35 | void onAddedDirty() {
36 | super.onAddedDirty();
37 | drawable = context.resolve(drawableId);
38 | }
39 |
40 | @override
41 | void placementValueChanged(int from, int to) {
42 | artboard?.markDrawOrderDirty();
43 | }
44 |
45 | @override
46 | void update(int dirt) {}
47 | }
48 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/keyframe_double_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/keyframe_double_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/keyframe.dart';
6 |
7 | abstract class KeyFrameDoubleBase extends KeyFrame {
8 | static const int typeKey = 30;
9 | @override
10 | int get coreType => KeyFrameDoubleBase.typeKey;
11 | @override
12 | Set get coreTypes => {KeyFrameDoubleBase.typeKey, KeyFrameBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// Value field with key 70.
16 | static const double valueInitialValue = 0;
17 | double _value = valueInitialValue;
18 | static const int valuePropertyKey = 70;
19 | double get value => _value;
20 |
21 | /// Change the [_value] field value.
22 | /// [valueChanged] will be invoked only if the field's value has changed.
23 | set value(double value) {
24 | if (_value == value) {
25 | return;
26 | }
27 | double from = _value;
28 | _value = value;
29 | if (hasValidated) {
30 | valueChanged(from, value);
31 | }
32 | }
33 |
34 | void valueChanged(double from, double to);
35 |
36 | @override
37 | void copy(covariant KeyFrameDoubleBase source) {
38 | super.copy(source);
39 | _value = source._value;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/generated/assets/file_asset_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/assets/file_asset_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/rive_core/assets/asset.dart';
5 |
6 | abstract class FileAssetBase extends Asset {
7 | static const int typeKey = 103;
8 | @override
9 | int get coreType => FileAssetBase.typeKey;
10 | @override
11 | Set get coreTypes => {FileAssetBase.typeKey, AssetBase.typeKey};
12 |
13 | /// --------------------------------------------------------------------------
14 | /// AssetId field with key 204.
15 | static const int assetIdInitialValue = 0;
16 | int _assetId = assetIdInitialValue;
17 | static const int assetIdPropertyKey = 204;
18 |
19 | /// Id of the asset as stored on the backend
20 | int get assetId => _assetId;
21 |
22 | /// Change the [_assetId] field value.
23 | /// [assetIdChanged] will be invoked only if the field's value has changed.
24 | set assetId(int value) {
25 | if (_assetId == value) {
26 | return;
27 | }
28 | int from = _assetId;
29 | _assetId = value;
30 | if (hasValidated) {
31 | assetIdChanged(from, value);
32 | }
33 | }
34 |
35 | void assetIdChanged(int from, int to);
36 |
37 | @override
38 | void copy(covariant FileAssetBase source) {
39 | super.copy(source);
40 | _assetId = source._assetId;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/blend_state_transition.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/generated/animation/blend_state_transition_base.dart';
2 | import 'package:rive/src/rive_core/animation/blend_animation.dart';
3 | import 'package:rive/src/rive_core/animation/blend_state_instance.dart';
4 | import 'package:rive/src/rive_core/animation/layer_state.dart';
5 | import 'package:rive/src/rive_core/animation/linear_animation.dart';
6 | import 'package:rive/src/rive_core/animation/linear_animation_instance.dart';
7 | import 'package:rive/src/rive_core/animation/state_instance.dart';
8 |
9 | export 'package:rive/src/generated/animation/blend_state_transition_base.dart';
10 |
11 | class BlendStateTransition extends BlendStateTransitionBase {
12 | BlendAnimation? exitBlendAnimation;
13 |
14 | @override
15 | LinearAnimationInstance? exitTimeAnimationInstance(StateInstance stateFrom) {
16 | if (stateFrom is BlendStateInstance) {
17 | for (final blendAnimation in stateFrom.animationInstances) {
18 | if (blendAnimation.blendAnimation == exitBlendAnimation) {
19 | return blendAnimation.animationInstance;
20 | }
21 | }
22 | }
23 | return null;
24 | }
25 |
26 | @override
27 | LinearAnimation? exitTimeAnimation(LayerState stateFrom) =>
28 | exitBlendAnimation?.animation;
29 |
30 | @override
31 | void exitBlendAnimationIdChanged(int from, int to) {}
32 | }
33 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/keyed_object_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/keyed_object_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/core/core.dart';
6 |
7 | abstract class KeyedObjectBase extends Core {
8 | static const int typeKey = 25;
9 | @override
10 | int get coreType => KeyedObjectBase.typeKey;
11 | @override
12 | Set get coreTypes => {KeyedObjectBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// ObjectId field with key 51.
16 | static const int objectIdInitialValue = 0;
17 | int _objectId = objectIdInitialValue;
18 | static const int objectIdPropertyKey = 51;
19 |
20 | /// Identifier used to track the object that is keyed.
21 | int get objectId => _objectId;
22 |
23 | /// Change the [_objectId] field value.
24 | /// [objectIdChanged] will be invoked only if the field's value has changed.
25 | set objectId(int value) {
26 | if (_objectId == value) {
27 | return;
28 | }
29 | int from = _objectId;
30 | _objectId = value;
31 | if (hasValidated) {
32 | objectIdChanged(from, value);
33 | }
34 | }
35 |
36 | void objectIdChanged(int from, int to);
37 |
38 | @override
39 | void copy(covariant KeyedObjectBase source) {
40 | _objectId = source._objectId;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/event_input_change_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/event_input_change_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/core/core.dart';
6 |
7 | abstract class EventInputChangeBase extends Core {
8 | static const int typeKey = 116;
9 | @override
10 | int get coreType => EventInputChangeBase.typeKey;
11 | @override
12 | Set get coreTypes => {EventInputChangeBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// InputId field with key 227.
16 | static const int inputIdInitialValue = -1;
17 | int _inputId = inputIdInitialValue;
18 | static const int inputIdPropertyKey = 227;
19 |
20 | /// Id of the StateMachineInput referenced.
21 | int get inputId => _inputId;
22 |
23 | /// Change the [_inputId] field value.
24 | /// [inputIdChanged] will be invoked only if the field's value has changed.
25 | set inputId(int value) {
26 | if (_inputId == value) {
27 | return;
28 | }
29 | int from = _inputId;
30 | _inputId = value;
31 | if (hasValidated) {
32 | inputIdChanged(from, value);
33 | }
34 | }
35 |
36 | void inputIdChanged(int from, int to);
37 |
38 | @override
39 | void copy(covariant EventInputChangeBase source) {
40 | _inputId = source._inputId;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/blend_animation_1d_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/blend_animation_1d_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/blend_animation.dart';
6 |
7 | abstract class BlendAnimation1DBase extends BlendAnimation {
8 | static const int typeKey = 75;
9 | @override
10 | int get coreType => BlendAnimation1DBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {BlendAnimation1DBase.typeKey, BlendAnimationBase.typeKey};
14 |
15 | /// --------------------------------------------------------------------------
16 | /// Value field with key 166.
17 | static const double valueInitialValue = 0;
18 | double _value = valueInitialValue;
19 | static const int valuePropertyKey = 166;
20 | double get value => _value;
21 |
22 | /// Change the [_value] field value.
23 | /// [valueChanged] will be invoked only if the field's value has changed.
24 | set value(double value) {
25 | if (_value == value) {
26 | return;
27 | }
28 | double from = _value;
29 | _value = value;
30 | if (hasValidated) {
31 | valueChanged(from, value);
32 | }
33 | }
34 |
35 | void valueChanged(double from, double to);
36 |
37 | @override
38 | void copy(covariant BlendAnimation1DBase source) {
39 | super.copy(source);
40 | _value = source._value;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/generated/assets/file_asset_contents_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/assets/file_asset_contents_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/core/core.dart';
6 |
7 | abstract class FileAssetContentsBase extends Core {
8 | static const int typeKey = 106;
9 | @override
10 | int get coreType => FileAssetContentsBase.typeKey;
11 | @override
12 | Set get coreTypes => {FileAssetContentsBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// Bytes field with key 212.
16 | static final Uint8List bytesInitialValue = Uint8List(0);
17 | Uint8List _bytes = bytesInitialValue;
18 | static const int bytesPropertyKey = 212;
19 |
20 | /// Byte data of the file.
21 | Uint8List get bytes => _bytes;
22 |
23 | /// Change the [_bytes] field value.
24 | /// [bytesChanged] will be invoked only if the field's value has changed.
25 | set bytes(Uint8List value) {
26 | if (listEquals(_bytes, value)) {
27 | return;
28 | }
29 | Uint8List from = _bytes;
30 | _bytes = value;
31 | if (hasValidated) {
32 | bytesChanged(from, value);
33 | }
34 | }
35 |
36 | void bytesChanged(Uint8List from, Uint8List to);
37 |
38 | @override
39 | void copy(covariant FileAssetContentsBase source) {
40 | _bytes = source._bytes;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/paint/solid_color_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/shapes/paint/solid_color_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/component.dart';
6 |
7 | abstract class SolidColorBase extends Component {
8 | static const int typeKey = 18;
9 | @override
10 | int get coreType => SolidColorBase.typeKey;
11 | @override
12 | Set get coreTypes => {SolidColorBase.typeKey, ComponentBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// ColorValue field with key 37.
16 | static const int colorValueInitialValue = 0xFF747474;
17 | int _colorValue = colorValueInitialValue;
18 | static const int colorValuePropertyKey = 37;
19 | int get colorValue => _colorValue;
20 |
21 | /// Change the [_colorValue] field value.
22 | /// [colorValueChanged] will be invoked only if the field's value has changed.
23 | set colorValue(int value) {
24 | if (_colorValue == value) {
25 | return;
26 | }
27 | int from = _colorValue;
28 | _colorValue = value;
29 | if (hasValidated) {
30 | colorValueChanged(from, value);
31 | }
32 | }
33 |
34 | void colorValueChanged(int from, int to);
35 |
36 | @override
37 | void copy(covariant SolidColorBase source) {
38 | super.copy(source);
39 | _colorValue = source._colorValue;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/transition_condition_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/transition_condition_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/core/core.dart';
6 |
7 | abstract class TransitionConditionBase extends Core {
8 | static const int typeKey = 67;
9 | @override
10 | int get coreType => TransitionConditionBase.typeKey;
11 | @override
12 | Set get coreTypes => {TransitionConditionBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// InputId field with key 155.
16 | static const int inputIdInitialValue = -1;
17 | int _inputId = inputIdInitialValue;
18 | static const int inputIdPropertyKey = 155;
19 |
20 | /// Id of the StateMachineInput referenced.
21 | int get inputId => _inputId;
22 |
23 | /// Change the [_inputId] field value.
24 | /// [inputIdChanged] will be invoked only if the field's value has changed.
25 | set inputId(int value) {
26 | if (_inputId == value) {
27 | return;
28 | }
29 | int from = _inputId;
30 | _inputId = value;
31 | if (hasValidated) {
32 | inputIdChanged(from, value);
33 | }
34 | }
35 |
36 | void inputIdChanged(int from, int to);
37 |
38 | @override
39 | void copy(covariant TransitionConditionBase source) {
40 | _inputId = source._inputId;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/controllers/one_shot_controller.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/widgets.dart';
2 | import 'package:rive/src/controllers/simple_controller.dart';
3 |
4 | /// Controller tailered for managing one-shot animations
5 | class OneShotAnimation extends SimpleAnimation {
6 | /// Fires when the animation stops being active
7 | final VoidCallback? onStop;
8 |
9 | /// Fires when the animation starts being active
10 | final VoidCallback? onStart;
11 |
12 | OneShotAnimation(
13 | String animationName, {
14 | double mix = 1,
15 | bool autoplay = true,
16 | this.onStop,
17 | this.onStart,
18 | }) : super(animationName, mix: mix, autoplay: autoplay) {
19 | isActiveChanged.addListener(onActiveChanged);
20 | }
21 |
22 | /// Dispose of any callback listeners
23 | @override
24 | void dispose() {
25 | super.dispose();
26 | isActiveChanged.removeListener(onActiveChanged);
27 | }
28 |
29 | /// Perform tasks when the animation's active state changes
30 | void onActiveChanged() {
31 | // If the animation stops and it is at the end of the one-shot, reset the
32 | // animation back to the starting time
33 | if (!isActive) {
34 | reset();
35 | }
36 | // Fire any callbacks
37 | isActive
38 | ? onStart?.call()
39 | // onStop can fire while widgets are still drawing
40 | : WidgetsBinding.instance.addPostFrameCallback((_) => onStop?.call());
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/example/lib/custom_controller.dart:
--------------------------------------------------------------------------------
1 | /// Demonstrates how to create a custom controller to change the speed of an
2 | /// animation
3 |
4 | import 'package:flutter/material.dart';
5 | import 'package:rive/rive.dart';
6 |
7 | class SpeedyAnimation extends StatelessWidget {
8 | const SpeedyAnimation({Key? key}) : super(key: key);
9 |
10 | @override
11 | Widget build(BuildContext context) {
12 | return Scaffold(
13 | appBar: AppBar(
14 | title: const Text('Custom Controller'),
15 | ),
16 | body: Center(
17 | child: RiveAnimation.network(
18 | 'https://cdn.rive.app/animations/vehicles.riv',
19 | fit: BoxFit.cover,
20 | animations: const ['idle'],
21 | controllers: [SpeedController('curves', speedMultiplier: 3)],
22 | ),
23 | ),
24 | );
25 | }
26 | }
27 |
28 | class SpeedController extends SimpleAnimation {
29 | final double speedMultiplier;
30 |
31 | SpeedController(
32 | String animationName, {
33 | double mix = 1,
34 | this.speedMultiplier = 1,
35 | }) : super(animationName, mix: mix);
36 |
37 | @override
38 | void apply(RuntimeArtboard artboard, double elapsedSeconds) {
39 | if (instance == null || !instance!.keepGoing) {
40 | isActive = false;
41 | }
42 | instance!
43 | ..animation.apply(instance!.time, coreContext: artboard, mix: mix)
44 | ..advance(elapsedSeconds * speedMultiplier);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/state_machine_double_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/state_machine_double_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/state_machine_component_base.dart';
6 | import 'package:rive/src/rive_core/animation/state_machine_input.dart';
7 |
8 | abstract class StateMachineDoubleBase extends StateMachineInput {
9 | static const int typeKey = 56;
10 | @override
11 | int get coreType => StateMachineDoubleBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | StateMachineDoubleBase.typeKey,
15 | StateMachineInputBase.typeKey,
16 | StateMachineComponentBase.typeKey
17 | };
18 |
19 | /// --------------------------------------------------------------------------
20 | /// Value field with key 140.
21 | static const double valueInitialValue = 0;
22 | double _value = valueInitialValue;
23 | static const int valuePropertyKey = 140;
24 | double get value => _value;
25 |
26 | /// Change the [_value] field value.
27 | /// [valueChanged] will be invoked only if the field's value has changed.
28 | set value(double value) {
29 | if (_value == value) {
30 | return;
31 | }
32 | double from = _value;
33 | _value = value;
34 | if (hasValidated) {
35 | valueChanged(from, value);
36 | }
37 | }
38 |
39 | void valueChanged(double from, double to);
40 | }
41 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/event_bool_change_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/event_bool_change_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/event_input_change.dart';
6 |
7 | abstract class EventBoolChangeBase extends EventInputChange {
8 | static const int typeKey = 117;
9 | @override
10 | int get coreType => EventBoolChangeBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {EventBoolChangeBase.typeKey, EventInputChangeBase.typeKey};
14 |
15 | /// --------------------------------------------------------------------------
16 | /// Value field with key 228.
17 | static const int valueInitialValue = 1;
18 | int _value = valueInitialValue;
19 | static const int valuePropertyKey = 228;
20 |
21 | /// Value to set the input to when the event occurs.
22 | int get value => _value;
23 |
24 | /// Change the [_value] field value.
25 | /// [valueChanged] will be invoked only if the field's value has changed.
26 | set value(int value) {
27 | if (_value == value) {
28 | return;
29 | }
30 | int from = _value;
31 | _value = value;
32 | if (hasValidated) {
33 | valueChanged(from, value);
34 | }
35 | }
36 |
37 | void valueChanged(int from, int to);
38 |
39 | @override
40 | void copy(covariant EventBoolChangeBase source) {
41 | super.copy(source);
42 | _value = source._value;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lib/src/generated/constraints/constraint_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/constraints/constraint_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/component.dart';
6 |
7 | abstract class ConstraintBase extends Component {
8 | static const int typeKey = 79;
9 | @override
10 | int get coreType => ConstraintBase.typeKey;
11 | @override
12 | Set get coreTypes => {ConstraintBase.typeKey, ComponentBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// Strength field with key 172.
16 | static const double strengthInitialValue = 1.0;
17 | double _strength = strengthInitialValue;
18 | static const int strengthPropertyKey = 172;
19 |
20 | /// Strength of the constraint. 0 means off. 1 means fully constraining.
21 | double get strength => _strength;
22 |
23 | /// Change the [_strength] field value.
24 | /// [strengthChanged] will be invoked only if the field's value has changed.
25 | set strength(double value) {
26 | if (_strength == value) {
27 | return;
28 | }
29 | double from = _strength;
30 | _strength = value;
31 | if (hasValidated) {
32 | strengthChanged(from, value);
33 | }
34 | }
35 |
36 | void strengthChanged(double from, double to);
37 |
38 | @override
39 | void copy(covariant ConstraintBase source) {
40 | super.copy(source);
41 | _strength = source._strength;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/blend_animation_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/blend_animation_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/core/core.dart';
6 |
7 | abstract class BlendAnimationBase extends Core {
8 | static const int typeKey = 74;
9 | @override
10 | int get coreType => BlendAnimationBase.typeKey;
11 | @override
12 | Set get coreTypes => {BlendAnimationBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// AnimationId field with key 165.
16 | static const int animationIdInitialValue = -1;
17 | int _animationId = animationIdInitialValue;
18 | static const int animationIdPropertyKey = 165;
19 |
20 | /// Id of the animation this BlendAnimation references.
21 | int get animationId => _animationId;
22 |
23 | /// Change the [_animationId] field value.
24 | /// [animationIdChanged] will be invoked only if the field's value has
25 | /// changed.
26 | set animationId(int value) {
27 | if (_animationId == value) {
28 | return;
29 | }
30 | int from = _animationId;
31 | _animationId = value;
32 | if (hasValidated) {
33 | animationIdChanged(from, value);
34 | }
35 | }
36 |
37 | void animationIdChanged(int from, int to);
38 |
39 | @override
40 | void copy(covariant BlendAnimationBase source) {
41 | _animationId = source._animationId;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/keyed_property_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/keyed_property_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/core/core.dart';
6 |
7 | abstract class KeyedPropertyBase extends Core {
8 | static const int typeKey = 26;
9 | @override
10 | int get coreType => KeyedPropertyBase.typeKey;
11 | @override
12 | Set get coreTypes => {KeyedPropertyBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// PropertyKey field with key 53.
16 | static const int propertyKeyInitialValue = CoreContext.invalidPropertyKey;
17 | int _propertyKey = propertyKeyInitialValue;
18 | static const int propertyKeyPropertyKey = 53;
19 |
20 | /// The property type that is keyed.
21 | int get propertyKey => _propertyKey;
22 |
23 | /// Change the [_propertyKey] field value.
24 | /// [propertyKeyChanged] will be invoked only if the field's value has
25 | /// changed.
26 | set propertyKey(int value) {
27 | if (_propertyKey == value) {
28 | return;
29 | }
30 | int from = _propertyKey;
31 | _propertyKey = value;
32 | if (hasValidated) {
33 | propertyKeyChanged(from, value);
34 | }
35 | }
36 |
37 | void propertyKeyChanged(int from, int to);
38 |
39 | @override
40 | void copy(covariant KeyedPropertyBase source) {
41 | _propertyKey = source._propertyKey;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/lib/src/core/importers/artboard_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/rive.dart';
2 | import 'package:rive/src/core/core.dart';
3 | import 'package:rive/src/rive_core/animation/animation.dart';
4 | import 'package:rive/src/rive_core/component.dart';
5 |
6 | class ArtboardImporter extends ImportStackObject {
7 | final RuntimeArtboard artboard;
8 | ArtboardImporter(this.artboard);
9 | final List animations = [];
10 |
11 | void addComponent(Core? object) => artboard.addObject(object);
12 |
13 | void addAnimation(Animation animation) {
14 | if (animation is LinearAnimation) {
15 | animations.add(animation);
16 | }
17 | artboard.addObject(animation);
18 | animation.artboard = artboard;
19 | }
20 |
21 | void addStateMachine(StateMachine animation) => addAnimation(animation);
22 |
23 | @override
24 | bool resolve() {
25 | for (final object in artboard.objects.skip(1)) {
26 | if (object is Component &&
27 | object.parentId == ComponentBase.parentIdInitialValue) {
28 | object.parent = artboard;
29 | }
30 | object?.onAddedDirty();
31 | }
32 | assert(!artboard.children.contains(artboard),
33 | 'artboard should never contain itself as a child');
34 | for (final object in artboard.objects.toList(growable: false)) {
35 | if (object == null) {
36 | continue;
37 | }
38 | object.onAdded();
39 | }
40 | artboard.clean();
41 | return true;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/straight_vertex.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/shapes/straight_vertex_base.dart';
3 | import 'package:rive/src/rive_core/bones/weight.dart';
4 | import 'package:rive/src/rive_core/component.dart';
5 | import 'package:rive/src/rive_core/math/vec2d.dart';
6 |
7 | export 'package:rive/src/generated/shapes/straight_vertex_base.dart';
8 |
9 | class StraightVertex extends StraightVertexBase {
10 | /// Nullable because not all vertices have weight, they only have it when the
11 | /// shape they are in is bound to bones.
12 | Weight? _weight;
13 |
14 | StraightVertex();
15 |
16 | /// Makes a vertex that is disconnected from core.
17 | StraightVertex.procedural() {
18 | InternalCoreHelper.markValid(this);
19 | }
20 |
21 | @override
22 | String toString() => 'x[$x], y[$y], r[$radius]';
23 |
24 | @override
25 | void radiusChanged(double from, double to) {
26 | path?.markPathDirty();
27 | }
28 |
29 | @override
30 | void childAdded(Component component) {
31 | super.childAdded(component);
32 | if (component is Weight) {
33 | _weight = component;
34 | }
35 | }
36 |
37 | @override
38 | void childRemoved(Component component) {
39 | super.childRemoved(component);
40 | if (_weight == component) {
41 | _weight = null;
42 | }
43 | }
44 |
45 | @override
46 | Vec2D get renderTranslation =>
47 | _weight?.translation ?? super.renderTranslation;
48 | }
49 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/event_number_change_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/event_number_change_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/event_input_change.dart';
6 |
7 | abstract class EventNumberChangeBase extends EventInputChange {
8 | static const int typeKey = 118;
9 | @override
10 | int get coreType => EventNumberChangeBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {EventNumberChangeBase.typeKey, EventInputChangeBase.typeKey};
14 |
15 | /// --------------------------------------------------------------------------
16 | /// Value field with key 229.
17 | static const double valueInitialValue = 0;
18 | double _value = valueInitialValue;
19 | static const int valuePropertyKey = 229;
20 |
21 | /// Value to set the input to when the event occurs.
22 | double get value => _value;
23 |
24 | /// Change the [_value] field value.
25 | /// [valueChanged] will be invoked only if the field's value has changed.
26 | set value(double value) {
27 | if (_value == value) {
28 | return;
29 | }
30 | double from = _value;
31 | _value = value;
32 | if (hasValidated) {
33 | valueChanged(from, value);
34 | }
35 | }
36 |
37 | void valueChanged(double from, double to);
38 |
39 | @override
40 | void copy(covariant EventNumberChangeBase source) {
41 | super.copy(source);
42 | _value = source._value;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/state_machine_component_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/state_machine_component_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/core/core.dart';
6 |
7 | abstract class StateMachineComponentBase
8 | extends Core {
9 | static const int typeKey = 54;
10 | @override
11 | int get coreType => StateMachineComponentBase.typeKey;
12 | @override
13 | Set get coreTypes => {StateMachineComponentBase.typeKey};
14 |
15 | /// --------------------------------------------------------------------------
16 | /// Name field with key 138.
17 | static const String nameInitialValue = '';
18 | String _name = nameInitialValue;
19 | static const int namePropertyKey = 138;
20 |
21 | /// Non-unique identifier, used to give friendly names to state machine
22 | /// components (like layers or inputs).
23 | String get name => _name;
24 |
25 | /// Change the [_name] field value.
26 | /// [nameChanged] will be invoked only if the field's value has changed.
27 | set name(String value) {
28 | if (_name == value) {
29 | return;
30 | }
31 | String from = _name;
32 | _name = value;
33 | if (hasValidated) {
34 | nameChanged(from, value);
35 | }
36 | }
37 |
38 | void nameChanged(String from, String to);
39 |
40 | @override
41 | void copy(covariant StateMachineComponentBase source) {
42 | _name = source._name;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/transition_double_condition_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/transition_double_condition_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/transition_condition_base.dart';
6 | import 'package:rive/src/rive_core/animation/transition_value_condition.dart';
7 |
8 | abstract class TransitionDoubleConditionBase extends TransitionValueCondition {
9 | static const int typeKey = 70;
10 | @override
11 | int get coreType => TransitionDoubleConditionBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | TransitionDoubleConditionBase.typeKey,
15 | TransitionValueConditionBase.typeKey,
16 | TransitionConditionBase.typeKey
17 | };
18 |
19 | /// --------------------------------------------------------------------------
20 | /// Value field with key 157.
21 | static const double valueInitialValue = 0;
22 | double _value = valueInitialValue;
23 | static const int valuePropertyKey = 157;
24 | double get value => _value;
25 |
26 | /// Change the [_value] field value.
27 | /// [valueChanged] will be invoked only if the field's value has changed.
28 | set value(double value) {
29 | if (_value == value) {
30 | return;
31 | }
32 | double from = _value;
33 | _value = value;
34 | if (hasValidated) {
35 | valueChanged(from, value);
36 | }
37 | }
38 |
39 | void valueChanged(double from, double to);
40 | }
41 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/keyframe_color.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | import 'package:rive/src/core/core.dart';
4 | import 'package:rive/src/generated/animation/keyframe_color_base.dart';
5 | export 'package:rive/src/generated/animation/keyframe_color_base.dart';
6 |
7 | void _apply(Core object, int propertyKey, double mix, int value) {
8 | if (mix == 1) {
9 | RiveCoreContext.setColor(object, propertyKey, value);
10 | } else {
11 | var mixedColor = Color.lerp(
12 | Color(RiveCoreContext.getColor(object, propertyKey)),
13 | Color(value),
14 | mix);
15 | if (mixedColor != null) {
16 | RiveCoreContext.setColor(object, propertyKey, mixedColor.value);
17 | }
18 | }
19 | }
20 |
21 | class KeyFrameColor extends KeyFrameColorBase {
22 | @override
23 | void apply(Core object, int propertyKey, double mix) =>
24 | _apply(object, propertyKey, mix, value);
25 |
26 | @override
27 | void applyInterpolation(Core object, int propertyKey,
28 | double currentTime, KeyFrameColor nextFrame, double mix) {
29 | var f = (currentTime - seconds) / (nextFrame.seconds - seconds);
30 |
31 | if (interpolator != null) {
32 | f = interpolator!.transform(f);
33 | }
34 |
35 | var color = Color.lerp(Color(value), Color(nextFrame.value), f);
36 | if (color != null) {
37 | _apply(object, propertyKey, mix, color.value);
38 | }
39 | }
40 |
41 | @override
42 | void valueChanged(int from, int to) {}
43 | }
44 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/layer_state.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/animation/layer_state_base.dart';
3 | import 'package:rive/src/rive_core/animation/state_instance.dart';
4 | import 'package:rive/src/rive_core/animation/state_machine_layer.dart';
5 | import 'package:rive/src/rive_core/animation/state_transition.dart';
6 |
7 | export 'package:rive/src/generated/animation/layer_state_base.dart';
8 |
9 | abstract class LayerState extends LayerStateBase {
10 | final StateTransitions _transitions = StateTransitions();
11 | StateTransitions get transitions => _transitions;
12 |
13 | @override
14 | void onAdded() {}
15 |
16 | @override
17 | void onAddedDirty() {}
18 |
19 | void internalAddTransition(StateTransition transition) {
20 | assert(!_transitions.contains(transition),
21 | 'shouldn\'t already contain the transition');
22 | _transitions.add(transition);
23 | }
24 |
25 | void internalRemoveTransition(StateTransition transition) {
26 | _transitions.remove(transition);
27 | }
28 |
29 | @override
30 | void onRemoved() {
31 | super.onRemoved();
32 | }
33 |
34 | StateInstance makeInstance();
35 |
36 | @override
37 | bool import(ImportStack stack) {
38 | var importer =
39 | stack.latest(StateMachineLayerBase.typeKey);
40 | if (importer == null) {
41 | return false;
42 | }
43 | importer.addState(this);
44 |
45 | return super.import(stack);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/lib/src/generated/nested_animation_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/nested_animation_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/rive_core/component.dart';
5 |
6 | abstract class NestedAnimationBase extends Component {
7 | static const int typeKey = 93;
8 | @override
9 | int get coreType => NestedAnimationBase.typeKey;
10 | @override
11 | Set get coreTypes =>
12 | {NestedAnimationBase.typeKey, ComponentBase.typeKey};
13 |
14 | /// --------------------------------------------------------------------------
15 | /// AnimationId field with key 198.
16 | static const int animationIdInitialValue = -1;
17 | int _animationId = animationIdInitialValue;
18 | static const int animationIdPropertyKey = 198;
19 |
20 | /// Identifier used to track the animation in the nested artboard.
21 | int get animationId => _animationId;
22 |
23 | /// Change the [_animationId] field value.
24 | /// [animationIdChanged] will be invoked only if the field's value has
25 | /// changed.
26 | set animationId(int value) {
27 | if (_animationId == value) {
28 | return;
29 | }
30 | int from = _animationId;
31 | _animationId = value;
32 | if (hasValidated) {
33 | animationIdChanged(from, value);
34 | }
35 | }
36 |
37 | void animationIdChanged(int from, int to);
38 |
39 | @override
40 | void copy(covariant NestedAnimationBase source) {
41 | super.copy(source);
42 | _animationId = source._animationId;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/blend_animation_direct_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/blend_animation_direct_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/blend_animation.dart';
6 |
7 | abstract class BlendAnimationDirectBase extends BlendAnimation {
8 | static const int typeKey = 77;
9 | @override
10 | int get coreType => BlendAnimationDirectBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {BlendAnimationDirectBase.typeKey, BlendAnimationBase.typeKey};
14 |
15 | /// --------------------------------------------------------------------------
16 | /// InputId field with key 168.
17 | static const int inputIdInitialValue = -1;
18 | int _inputId = inputIdInitialValue;
19 | static const int inputIdPropertyKey = 168;
20 |
21 | /// Id of the input that drives the direct mix value for this animation.
22 | int get inputId => _inputId;
23 |
24 | /// Change the [_inputId] field value.
25 | /// [inputIdChanged] will be invoked only if the field's value has changed.
26 | set inputId(int value) {
27 | if (_inputId == value) {
28 | return;
29 | }
30 | int from = _inputId;
31 | _inputId = value;
32 | if (hasValidated) {
33 | inputIdChanged(from, value);
34 | }
35 | }
36 |
37 | void inputIdChanged(int from, int to);
38 |
39 | @override
40 | void copy(covariant BlendAnimationDirectBase source) {
41 | super.copy(source);
42 | _inputId = source._inputId;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lib/src/rive_core/shapes/star.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math';
2 |
3 | import 'package:rive/src/generated/shapes/star_base.dart';
4 | import 'package:rive/src/rive_core/bones/weight.dart';
5 | import 'package:rive/src/rive_core/shapes/path_vertex.dart';
6 | import 'package:rive/src/rive_core/shapes/straight_vertex.dart';
7 |
8 | export 'package:rive/src/generated/shapes/star_base.dart';
9 |
10 | class Star extends StarBase {
11 | @override
12 | void innerRadiusChanged(double from, double to) => markPathDirty();
13 |
14 | @override
15 | List> get vertices {
16 | double ox = -originX * width + width / 2;
17 | double oy = -originY * height + height / 2;
18 |
19 | var actualPoints = points * 2;
20 | var vertexList = >[];
21 | var halfWidth = width / 2;
22 | var halfHeight = height / 2;
23 | var innerHalfWidth = width * innerRadius / 2;
24 | var innerHalfHeight = height * innerRadius / 2;
25 | var angle = -pi / 2;
26 | var inc = 2 * pi / actualPoints;
27 | while (vertexList.length < actualPoints) {
28 | vertexList.add(StraightVertex.procedural()
29 | ..x = ox + cos(angle) * halfWidth
30 | ..y = oy + sin(angle) * halfHeight
31 | ..radius = cornerRadius);
32 | angle += inc;
33 | vertexList.add(StraightVertex.procedural()
34 | ..x = ox + cos(angle) * innerHalfWidth
35 | ..y = oy + sin(angle) * innerHalfHeight
36 | ..radius = cornerRadius);
37 | angle += inc;
38 | }
39 | return vertexList;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/core/importers/state_machine_layer_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/rive.dart';
2 | import 'package:rive/src/core/core.dart';
3 | import 'package:rive/src/rive_core/animation/layer_state.dart';
4 | import 'package:rive/src/rive_core/animation/state_machine_layer.dart';
5 |
6 | class StateMachineLayerImporter extends ImportStackObject {
7 | final StateMachineLayer layer;
8 | StateMachineLayerImporter(this.layer);
9 |
10 | final List importedStates = [];
11 |
12 | void addState(LayerState state) {
13 | importedStates.add(state);
14 | // Here the state gets assigned a core (artboard) id.
15 | layer.context.addObject(state);
16 | layer.internalAddState(state);
17 | }
18 |
19 | @override
20 | int get resolvesBefore => StateMachineBase.typeKey;
21 |
22 | bool _resolved = false;
23 | @override
24 | bool resolve() {
25 | assert(!_resolved);
26 | _resolved = true;
27 | for (final state in importedStates) {
28 | for (final transition in state.transitions) {
29 | // At import time the stateToId is an index relative to the entire layer
30 | // (which state in this layer). We can use that to find the matching
31 | // importedState and assign back the core id that will resolve after the
32 | // entire artboard imports.
33 | if (transition.stateToId >= 0 &&
34 | transition.stateToId < importedStates.length) {
35 | transition.stateTo = importedStates[transition.stateToId];
36 | }
37 | }
38 | }
39 | return true;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/transition_value_condition_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/transition_value_condition_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/rive_core/animation/transition_condition.dart';
6 |
7 | abstract class TransitionValueConditionBase extends TransitionCondition {
8 | static const int typeKey = 69;
9 | @override
10 | int get coreType => TransitionValueConditionBase.typeKey;
11 | @override
12 | Set get coreTypes =>
13 | {TransitionValueConditionBase.typeKey, TransitionConditionBase.typeKey};
14 |
15 | /// --------------------------------------------------------------------------
16 | /// OpValue field with key 156.
17 | static const int opValueInitialValue = 0;
18 | int _opValue = opValueInitialValue;
19 | static const int opValuePropertyKey = 156;
20 |
21 | /// Integer representation of the StateMachineOp enum.
22 | int get opValue => _opValue;
23 |
24 | /// Change the [_opValue] field value.
25 | /// [opValueChanged] will be invoked only if the field's value has changed.
26 | set opValue(int value) {
27 | if (_opValue == value) {
28 | return;
29 | }
30 | int from = _opValue;
31 | _opValue = value;
32 | if (hasValidated) {
33 | opValueChanged(from, value);
34 | }
35 | }
36 |
37 | void opValueChanged(int from, int to);
38 |
39 | @override
40 | void copy(covariant TransitionValueConditionBase source) {
41 | super.copy(source);
42 | _opValue = source._opValue;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lib/rive.dart:
--------------------------------------------------------------------------------
1 | library rive;
2 |
3 | export 'package:rive/src/controllers/one_shot_controller.dart';
4 | export 'package:rive/src/controllers/simple_controller.dart';
5 | export 'package:rive/src/controllers/state_machine_controller.dart';
6 | export 'package:rive/src/extensions.dart';
7 | export 'package:rive/src/extensions.dart';
8 | export 'package:rive/src/rive.dart';
9 | export 'package:rive/src/rive_core/animation/linear_animation.dart';
10 | export 'package:rive/src/rive_core/animation/linear_animation_instance.dart';
11 | export 'package:rive/src/rive_core/animation/loop.dart';
12 | export 'package:rive/src/rive_core/animation/state_machine.dart';
13 | export 'package:rive/src/rive_core/artboard.dart';
14 | export 'package:rive/src/rive_core/rive_animation_controller.dart';
15 | export 'package:rive/src/rive_core/runtime/exceptions/rive_format_error_exception.dart';
16 | export 'package:rive/src/rive_core/runtime/runtime_header.dart'
17 | show riveVersion;
18 | export 'package:rive/src/rive_core/shapes/paint/fill.dart';
19 | export 'package:rive/src/rive_core/shapes/paint/linear_gradient.dart';
20 | export 'package:rive/src/rive_core/shapes/paint/radial_gradient.dart';
21 | export 'package:rive/src/rive_core/shapes/paint/solid_color.dart';
22 | export 'package:rive/src/rive_core/shapes/paint/stroke.dart';
23 | export 'package:rive/src/rive_core/shapes/shape.dart';
24 | export 'package:rive/src/rive_file.dart';
25 | export 'package:rive/src/rive_scene.dart';
26 | export 'package:rive/src/runtime_artboard.dart';
27 | export 'package:rive/src/widgets/rive_animation.dart';
28 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/state_machine_bool_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/state_machine_bool_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/state_machine_component_base.dart';
6 | import 'package:rive/src/rive_core/animation/state_machine_input.dart';
7 |
8 | abstract class StateMachineBoolBase extends StateMachineInput {
9 | static const int typeKey = 59;
10 | @override
11 | int get coreType => StateMachineBoolBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | StateMachineBoolBase.typeKey,
15 | StateMachineInputBase.typeKey,
16 | StateMachineComponentBase.typeKey
17 | };
18 |
19 | /// --------------------------------------------------------------------------
20 | /// Value field with key 141.
21 | static const bool valueInitialValue = false;
22 | bool _value = valueInitialValue;
23 | static const int valuePropertyKey = 141;
24 | bool get value => _value;
25 |
26 | /// Change the [_value] field value.
27 | /// [valueChanged] will be invoked only if the field's value has changed.
28 | set value(bool value) {
29 | if (_value == value) {
30 | return;
31 | }
32 | bool from = _value;
33 | _value = value;
34 | if (hasValidated) {
35 | valueChanged(from, value);
36 | }
37 | }
38 |
39 | void valueChanged(bool from, bool to);
40 |
41 | @override
42 | void copy(covariant StateMachineBoolBase source) {
43 | super.copy(source);
44 | _value = source._value;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/src/generated/animation/state_machine_number_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/animation/state_machine_number_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/animation/state_machine_component_base.dart';
6 | import 'package:rive/src/rive_core/animation/state_machine_input.dart';
7 |
8 | abstract class StateMachineNumberBase extends StateMachineInput {
9 | static const int typeKey = 56;
10 | @override
11 | int get coreType => StateMachineNumberBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | StateMachineNumberBase.typeKey,
15 | StateMachineInputBase.typeKey,
16 | StateMachineComponentBase.typeKey
17 | };
18 |
19 | /// --------------------------------------------------------------------------
20 | /// Value field with key 140.
21 | static const double valueInitialValue = 0;
22 | double _value = valueInitialValue;
23 | static const int valuePropertyKey = 140;
24 | double get value => _value;
25 |
26 | /// Change the [_value] field value.
27 | /// [valueChanged] will be invoked only if the field's value has changed.
28 | set value(double value) {
29 | if (_value == value) {
30 | return;
31 | }
32 | double from = _value;
33 | _value = value;
34 | if (hasValidated) {
35 | valueChanged(from, value);
36 | }
37 | }
38 |
39 | void valueChanged(double from, double to);
40 |
41 | @override
42 | void copy(covariant StateMachineNumberBase source) {
43 | super.copy(source);
44 | _value = source._value;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/paint/fill_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated lib/src/generated/shapes/paint/fill_base.dart.
2 | /// Do not modify manually.
3 |
4 | import 'package:rive/src/generated/component_base.dart';
5 | import 'package:rive/src/generated/container_component_base.dart';
6 | import 'package:rive/src/rive_core/shapes/paint/shape_paint.dart';
7 |
8 | abstract class FillBase extends ShapePaint {
9 | static const int typeKey = 20;
10 | @override
11 | int get coreType => FillBase.typeKey;
12 | @override
13 | Set get coreTypes => {
14 | FillBase.typeKey,
15 | ShapePaintBase.typeKey,
16 | ContainerComponentBase.typeKey,
17 | ComponentBase.typeKey
18 | };
19 |
20 | /// --------------------------------------------------------------------------
21 | /// FillRule field with key 40.
22 | static const int fillRuleInitialValue = 0;
23 | int _fillRule = fillRuleInitialValue;
24 | static const int fillRulePropertyKey = 40;
25 | int get fillRule => _fillRule;
26 |
27 | /// Change the [_fillRule] field value.
28 | /// [fillRuleChanged] will be invoked only if the field's value has changed.
29 | set fillRule(int value) {
30 | if (_fillRule == value) {
31 | return;
32 | }
33 | int from = _fillRule;
34 | _fillRule = value;
35 | if (hasValidated) {
36 | fillRuleChanged(from, value);
37 | }
38 | }
39 |
40 | void fillRuleChanged(int from, int to);
41 |
42 | @override
43 | void copy(covariant FillBase source) {
44 | super.copy(source);
45 | _fillRule = source._fillRule;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/lib/src/core/importers/layer_state_importer.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/importers/artboard_import_stack_object.dart';
2 | import 'package:rive/src/rive_core/animation/blend_animation.dart';
3 | import 'package:rive/src/rive_core/animation/blend_state.dart';
4 | import 'package:rive/src/rive_core/animation/blend_state_transition.dart';
5 | import 'package:rive/src/rive_core/animation/layer_state.dart';
6 | import 'package:rive/src/rive_core/animation/state_transition.dart';
7 |
8 | class LayerStateImporter extends ArtboardImportStackObject {
9 | final LayerState state;
10 | LayerStateImporter(this.state);
11 |
12 | void addTransition(StateTransition transition) {
13 | state.context.addObject(transition);
14 | state.internalAddTransition(transition);
15 | }
16 |
17 | bool addBlendAnimation(BlendAnimation blendAnimation) {
18 | // This works because we explicitly export our transitions before our
19 | // animations.
20 | if (state is BlendState) {
21 | var blendState = state as BlendState;
22 | for (final transition
23 | in state.transitions.whereType()) {
24 | if (transition.exitBlendAnimationId >= 0 &&
25 | transition.exitBlendAnimationId < blendState.animations.length) {
26 | transition.exitBlendAnimation =
27 | blendState.animations[transition.exitBlendAnimationId];
28 | }
29 | }
30 | }
31 | if (state is BlendState) {
32 | (state as BlendState).internalAddAnimation(blendAnimation);
33 | return true;
34 | }
35 |
36 | return false;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/src/rive_core/animation/transition_number_condition.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 |
3 | import 'package:rive/src/generated/animation/transition_number_condition_base.dart';
4 | import 'package:rive/src/rive_core/animation/state_machine_number.dart';
5 | import 'package:rive/src/rive_core/animation/transition_condition.dart';
6 |
7 | export 'package:rive/src/generated/animation/transition_number_condition_base.dart';
8 |
9 | class TransitionNumberCondition extends TransitionNumberConditionBase {
10 | @override
11 | void valueChanged(double from, double to) {}
12 |
13 | @override
14 | bool validate() => super.validate() && (input is StateMachineNumber);
15 |
16 | @override
17 | bool evaluate(HashMap values) {
18 | if (input is! StateMachineNumber) {
19 | return true;
20 | }
21 | var doubleInput = input as StateMachineNumber;
22 | dynamic providedValue = values[input.id];
23 | double inputValue =
24 | providedValue is double ? providedValue : doubleInput.value;
25 | switch (op) {
26 | case TransitionConditionOp.equal:
27 | return inputValue == value;
28 | case TransitionConditionOp.notEqual:
29 | return inputValue != value;
30 | case TransitionConditionOp.lessThanOrEqual:
31 | return inputValue <= value;
32 | case TransitionConditionOp.lessThan:
33 | return inputValue < value;
34 | case TransitionConditionOp.greaterThanOrEqual:
35 | return inputValue >= value;
36 | case TransitionConditionOp.greaterThan:
37 | return inputValue > value;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/lib/src/rive_core/draw_rules.dart:
--------------------------------------------------------------------------------
1 | import 'package:rive/src/core/core.dart';
2 | import 'package:rive/src/generated/draw_rules_base.dart';
3 | import 'package:rive/src/rive_core/component.dart';
4 | import 'package:rive/src/rive_core/draw_target.dart';
5 |
6 | export 'package:rive/src/generated/draw_rules_base.dart';
7 |
8 | class DrawRules extends DrawRulesBase {
9 | final Set _targets = {};
10 | Set get targets => _targets;
11 |
12 | DrawTarget? _activeTarget;
13 | DrawTarget? get activeTarget => _activeTarget;
14 | set activeTarget(DrawTarget? value) =>
15 | drawTargetId = value?.id ?? Core.missingId;
16 |
17 | @override
18 | void drawTargetIdChanged(int from, int to) {
19 | _activeTarget = context.resolve(to);
20 | artboard?.markDrawOrderDirty();
21 | }
22 |
23 | @override
24 | void onAddedDirty() {
25 | super.onAddedDirty();
26 | _activeTarget = context.resolve(drawTargetId);
27 | }
28 |
29 | @override
30 | void update(int dirt) {}
31 |
32 | @override
33 | void childAdded(Component child) {
34 | super.childAdded(child);
35 | switch (child.coreType) {
36 | case DrawTargetBase.typeKey:
37 | _targets.add(child as DrawTarget);
38 |
39 | break;
40 | }
41 | }
42 |
43 | @override
44 | void childRemoved(Component child) {
45 | super.childRemoved(child);
46 | switch (child.coreType) {
47 | case DrawTargetBase.typeKey:
48 | _targets.remove(child as DrawTarget);
49 | if (_targets.isEmpty) {
50 | remove();
51 | }
52 |
53 | break;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/test/artboard_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_test/flutter_test.dart';
2 | import 'package:rive/rive.dart';
3 |
4 | import 'src/utils.dart';
5 |
6 | void main() {
7 | late RiveFile riveFile;
8 |
9 | setUp(() {
10 | final riveBytes = loadFile('assets/rive-flutter-test-asset.riv');
11 | riveFile = RiveFile.import(riveBytes);
12 | });
13 |
14 | test('Artboards can be read from files', () {
15 | expect(riveFile.mainArtboard.name, 'Artboard 1');
16 | expect(riveFile.artboards.length, 2);
17 | expect(riveFile.artboardByName('Artboard 2'), isNotNull);
18 | });
19 |
20 | test('Animations can be read from artboards', () {
21 | final artboard = riveFile.mainArtboard;
22 | expect(artboard.animations.length, 3);
23 | expect(artboard.animations.first.name, 'Animation 1');
24 | expect(artboard.animations[1].name, 'Animation 2');
25 | expect(artboard.animations.last.name, 'State Machine 1');
26 | });
27 |
28 | test('Animations can be read by name from artboards', () {
29 | final artboard = riveFile.mainArtboard;
30 | expect(artboard.animationByName('Animation 1'), isNotNull);
31 | expect(artboard.animationByName('Animation 2'), isNotNull);
32 | expect(artboard.animationByName('Does Not Exist'), isNull);
33 | expect(artboard.animationByName('Animation 1') is LinearAnimationInstance,
34 | true);
35 | });
36 |
37 | test('Linear animations can be retreived ffrom artboards', () {
38 | final artboard = riveFile.mainArtboard;
39 | expect(artboard.linearAnimations.toList().length, 2);
40 | expect(artboard.stateMachines.toList().length, 1);
41 | });
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/generated/shapes/paint/shape_paint_base.dart:
--------------------------------------------------------------------------------
1 | /// Core automatically generated
2 | /// lib/src/generated/shapes/paint/shape_paint_base.dart.
3 | /// Do not modify manually.
4 |
5 | import 'package:rive/src/generated/component_base.dart';
6 | import 'package:rive/src/generated/container_component_base.dart';
7 | import 'package:rive/src/rive_core/container_component.dart';
8 |
9 | abstract class ShapePaintBase extends ContainerComponent {
10 | static const int typeKey = 21;
11 | @override
12 | int get coreType => ShapePaintBase.typeKey;
13 | @override
14 | Set get coreTypes => {
15 | ShapePaintBase.typeKey,
16 | ContainerComponentBase.typeKey,
17 | ComponentBase.typeKey
18 | };
19 |
20 | /// --------------------------------------------------------------------------
21 | /// IsVisible field with key 41.
22 | static const bool isVisibleInitialValue = true;
23 | bool _isVisible = isVisibleInitialValue;
24 | static const int isVisiblePropertyKey = 41;
25 | bool get isVisible => _isVisible;
26 |
27 | /// Change the [_isVisible] field value.
28 | /// [isVisibleChanged] will be invoked only if the field's value has changed.
29 | set isVisible(bool value) {
30 | if (_isVisible == value) {
31 | return;
32 | }
33 | bool from = _isVisible;
34 | _isVisible = value;
35 | if (hasValidated) {
36 | isVisibleChanged(from, value);
37 | }
38 | }
39 |
40 | void isVisibleChanged(bool from, bool to);
41 |
42 | @override
43 | void copy(covariant ShapePaintBase source) {
44 | super.copy(source);
45 | _isVisible = source._isVisible;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------