How to add Rive animations in Flutter
Answered my own question to share my knowledge
Creating animation is now really easy with the help of the Rive Cloud App, which lets you generate flr files which can then be used to run on the Flutter App.
Here is the step by step process to implement rive in our flutter app
- The first step is to go on https://rive.app/explore/popular/trending/all . and create or also any of the animations you want export animations that were created by some other users. Click any animation and Click Open in Rive. Then download it by clicking the export button.
-
Now, open VS Code or Android Studio and create new folder assets in the root directory of the application and paste the files which you have downloaded from rive. I have 2 files in the assets folder.
-
Now since the animation is completed and loaded on the Project. Add
rive
andflare_flutter
plugin in dependencies in yourpubspec.yaml
file : -
However, now we will create a simple Widget that loads one of the animations using the field
animation
available with theFlareActor
widget.FlareActor( 'assets/loading_animation_sun_flare.flr', animation: 'My Test', )
Note: Don’t forget to give the type of animation field that you set Animation name on Rive like in this example I set “My Test” And “Untitled” in FlareActor Widget otherwise, you will not get any animation effect.
Here is the full code:
import 'package:flutter/material.dart';
import 'package:flare_flutter/flare_actor.dart';
void main() => runApp(HomePage());
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Coflutter - Dismiss Keyboard',
home: Scaffold(
appBar: AppBar(
title: const Text('Rive Animation'),
backgroundColor: Colors.deepPurple,
),
body: RiveAnimationPage(),
),
);
}
}
class RiveAnimationPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
width: 700,
height: 300,
child: FlareActor(
"assets/loading_animation_sun_flare.flr",
animation: "My Test",
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 400,
height: 400,
child: FlareActor(
'assets/Success_Check.flr',
animation: 'Untitled',
)
),
)
],
)
);
}
}
For more info, see: https://androidmonks.com/flutter-rive-animated-buttons/
Paresh Mangukiya
I am a Mobile App Developer and Team Leader at BlueBit Technologies, in this My core competency lies in the complete end-to-end management and completing the entire project (iOS, Android and Backend side). I am seeking opportunities to build Mobile Apps from the ground up for you or your business. Please feel free to contact me here ⬇ Skype: pkmangukiya_1 Mobile or WhatsApp: +91 9723680658 Email: [email protected] I have spent 4+ years in the IT industry, I have developed a wide range of (iOS and Android) Applications using iOS (Swift, Objective-C), Flutter(Dart) and Android (Kotlin, Java). I work with B2B clients - Software companies and as well as B2C - Small and Medium Enterprises (SME) in many vertical industries and I passionate about good service & deliver a high-quality product. I have experience in mobile Application Development, App principles, processes, theories and concepts. I am involved in the full life cycle of designing, developing, testing, Analysis, and maintaining applications. And I have also enough knowledge and experience of how to use and where to use Encryption, Exception Handling, Token-based Authentication and other security features in applications. My core competency lies in complete end-to-end management of new Mobile Applications and I am seeking opportunities to build Mobile Apps from the ground up for you or your business. My experience has been awesome and good so far, I have learned a lot of new things and worked during this time. My years of experience have prepared me well for this position. Skills: Programming Languages: iOS: Swift and Objective C Flutter: Dart Android: Java and Kotlin C/C++ Professional Experience: Socket Programming DB & API Design Google API, Facebook API, Google Maps and Direction, Location Services Integrating ads ( Google Ads, Admob, Facebook Ads), Media Player Functionalities API security with JWT JSON, XML In-app purchase User Authentication Chat and Messaging Hosting (App Store, Play Store) Payment Gateways Social Media Integration SQLite Database, Firebase Database, MySQL Database Advanced Analytics Mobile Application Design Document Conversion Projects Variations: Chatting and Messaging: Text and Voice messaging, video communication, photo & video sharing Loan Management System Online Music Streaming QR & Barcode Scanner Parking Facility Social Media: Professional networks, social networks and Data Sharing Lifestyle: Religion, travel, blogs, fashion, health, fitness Music + Audio Video Mixer with dynamic features Football Training Club and Academy Photo and Video Editor App Organization Management Society management Quiz - Play & Win I really enjoy programming a lot!
Updated on December 01, 2022Comments
-
Paresh Mangukiya over 1 year
As know everyone Rive is a very useful animation tool that can create beautiful animations and we can add these to our Application. But how can we implement and how to create a super cool Animation using the Rive App and flare_flutter plugin?