Using Dart and Firebase

I was inspired to use Firebase with Dart by Jana Moudrá‘s talk at this year’s Dart Developer Summit (on YouTube here).

Firebase’s major contribution is having a backend for your app without writing a backend. It also handles user authorization flow, which if you’ve ever written login scripts yourself, you know this is a relief. It’s other killer feature (as if it needed one) is the ability to listen for relevant changes to the database in real-time. Behind the scenes, your app uses an open, idle websocket to send and receive data.

I’ve written applications with websockets myself before, using the Google App Engine. It’s a lot of hoops to jump through, with the requirement of a backend server, so having a ready built solution is a joyous change.

Without too much sweat, I was able to get users to log in using Firebase, then start tracking their statistics. I don’t have a use for the real-time database updates, but coding with or without them is more or less effortless. The data was always a simple function call away.

Structuring the database as (essentially) a json object took me a while to wrap my head around, but now that it’s done, I’ll happily use it again.

I plan to move all of my websocket traffic to this service in time – ultimately, once it’s set up, it’s just less for me to think about. Firebase is a fast, stable, simple and powerful service, and I can’t recommend it enough.

Firebase in the Dart Pub Package manager here. Enjoy.

1 Comment

  1. Hi, yes, I’ve just managed to get it going this week. I’m just doing the ui for users to log in, log out etc. I don’t need real time db updates, just to read at the start of a session and save at the end. My app data is already stored as a map in indexeddb, so hopefully it will go straight into FB db without modification. Users will be able to share data, and also work on it on different devices. Also hopefully, I’ll be finished soon to update my website.
    A fantastic service/product, highly recommended.


Leave a Reply

Your email address will not be published. Required fields are marked *