we know that adding some important features to your app like authentication & registration is a pain in the neck and you are probably looking for some final fix for your data storage and registration process for the flutter project, then this article is a must-read for you.
Flutter is a rapidly growing technology in today's world. Each year we build abundant apps for our clients using Flutter. It allows us to develop cross-platform applications for all operating systems, however, it’s mostly used for Android and iOS. While developing different kinds of apps and software we often require authentication, registration (sign-in/sign-up), and data storage features, for instance in games you must save players' info and ranking. We generally use Firebase for this purpose, it’s also our team’s favorite tool to use with Flutter.
Firebase is a Google-backed application development software that allows developers to build iOS, Android, and Web apps. It provides tools for tracking analytics, reporting and fixing app crashes, creating marketing and product experiments.
Recently, we’ve successfully integrated Firebase in one of our flutter game apps “The Werewolves Escape” in which we have added a quick & smooth registration (sign-in/sign-up) process along with a leaderboard that keeps a record of players ranking and keeps the spirit of playing alive.
For the registration process, we’ve used Firebase authentication that provides backend services, ready-made UI libraries, and easy-to-use SDKs. It helps to authenticate users to your app using special passwords, phone numbers, prevalent identity providers like Google, Twitter, Facebook, etc.
Firebase Authentication strongly integrates with other Firebase services, and it leverages industry levels such as OAuth 2.0 and OpenID Connect, so it can be easily integrated with your custom backend.
For the leaderboard, we’ve utilized Firestore which is a NoSQL Database like a real-time database, but the difference lies in the structure of data storage. Real-time database stockpiles data in a JSON tree.
Here are some steps to create a new project on Firebase
- Create a project file in the Firebase console.
- Add two apps one for android and the other for IOS
- Register the IOS app to firebase with the bundle id of the App
- Download Google Service-info for your app and add it to your project folder.
- Complete the next steps on the firebase console.
- Register your android app
- Download the config file google services.json and set it in the application module of an android project.
On the Firebase console from the left menu select the Database option to create a Cloud Firestore database. Select security rules for the database and then select test mode, it will make the database public, anyone can read and write to this database.
In Cloud Firestore we have a collection. A collection can have any number of Documents, which contain data. It scales automatically. The current scaling limit is around 1 million concurrent connections & approx.