Rive is a very useful animation tool that can create beautiful animations and we can add these in our Application. In flutter, we can add animations by writing so many lines of code but this is not a good practice for a developer. Instead of writing lines of code to create animation, we can create one using this powerful Rive animation tool. Please read all the below points in sequence to understand the topic clearly.
- Create a new Flutter application using command Prompt. For creating a new app, write flutter create YOUR_APP_NAME and run this command.
- Open the app in VS Code or in Android Studio. I am using VS Code.
- Delete the default code from main.dart file for now.
- Now to create new animation go ahead to https://rive.app/explore/popular/trending/all .
- You can also 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.
- The file extension should be .flr and format should be Binary.
- Now, open VS Code and create new folder “assets” in the root directory of the application and paste the files which you have downloaded from rive. I have 4 files in the assets folder.
-android -assets -my.flr -teddy.flr -test2.flr -test3.flr -build -ios -lib -main.dart -test -web -pubspec.lock -pubspec.yaml -README.md -rive_flutter.iml
- Now, edit pubspec.yaml file :
- Add rive in dependencies :
- Add assets in flutter:
- After that, open main.dart file as we are going to write the code in this file.
- Delete all the code from the main.dart file and write the below code to add animations to our application.
- We will display these animations on our Home Screen. Don’t forget to give the type of animation in FlareActor Widget otherwise, you will not get any animation effect.
- Run the app by writing command flutter run in terminal and see the output.
Complete code is available on https://github.com/singhteekam/rive-flutter .
- Difference Between Rows and Columns vs Container in Flutter
- Container class in Flutter
- Difference Between Stateless and Stateful Widget in Flutter
- ProgressIndicator in Flutter
- Flutter - Stateful vs Stateless Widgets
- Listview.builder in Flutter
- Splash Screen in Flutter
- How to Add images in Flutter App?
- Raised Button widget in Flutter
- Fluttertoast in Flutter
- Designing a Form Submission Page in Flutter
- Creating a Simple Application in Flutter
- Customizing Fonts in Flutter
- Android Studio Setup for Flutter Development
- How to Add Space Between Widgets in Flutter?
- Retrieve Data From TextFields in Flutter
- FittedBox in Flutter
- FlatButton Widget in Flutter
- Background local notifications in Flutter
- Restrict Landscape mode in Flutter
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.