How we developed the Cinebur App on Flutter: Part II

A deep-dive into the Flutter framework with code examples

Cinebur
Lumen: Blog by Cinebur
6 min readJan 4, 2021

--

Hey, everybody. Adrian here, co-founder & CTO of Cinebur. Today, I’m going to be diving even deeper into the Flutter framework, and even providing some helpful code examples I wish I had when I was starting out. If you missed Part I, feel free to read it here before starting. Otherwise, let’s go for it!

Flutter

Okay, so there are three things to pay attention to: state management, modularity and null point exceptions. The more technically informed audience will know where this is going. Although flutter at this point has begun to see wide scale adoption, it was still a relatively new framework when we started out — where developers are still tinkering, trying to find the best practices and optimal approaches to typical frontend tasks. We’ve shipped over 16 builds to productions at this point, some fixed errors, others introduced new ones, and some exposed errors that we hadn’t initially taken into considerations as we added more and more abilities for the users to interact with the product. Story of a developer’s life, am I right?

I have three pieces of advice for any would-be flutter devs or those thinking of trying out flutter to build out a full project:

  • Read the right documentation: Use the “Provider” package from pub.dev for all your state management needs; it is a very flutter way of doing things, which makes it easier to work within the greater context of your program, since it fits your needs in a consistent framework.
  • Recycle in your design: Try your best to identify recurring widgets in the design before you set out to code anything. Make those widgets first; then sprinkle them around your application as appropriate. Careful, don’t be afraid to break larger widgets into smaller ones that are parameterized for different situations.
  • Safeguard silly mistakes: I’ve been coding for over 6–7 years now in total, so I thought I was past the point of “divide-by-zero” errors or infinity errors — apparently not! Dart (the language behind flutter) is set to introduce null-safety features in an upcoming release 1.24; but until then, make sure you check all your values for the database and try to identify where numerical operations occur in order to add guard rails to prevent errors popping up to your users.

Here are some code snippets to show you what I mean:

Using a Provider for State Management

Making widgets modular

(This helps if you have normalized your database scheme beforehand.)

One of my favorite widgets is actually the heart button I made, the way it’s designed means it can take any resource (venue, event, movie, production member, review, etc…) and like or unlike it without having to know what the underlying resource is:

Checking for mistakes

Don’t forget to check your arithmetic operations!

One last horror story

These pointers aside, a funny story about our initial launch; we managed to get Stripe payments to work on iOS but not on Android, and yet we could only release the app at the time on Android and not iOS — the classic catch 22! We frantically scrambled to fix the problem, already at wits end and having been awake for over 28 hours. Finally, the solution was to roll back to an earlier version of the flutter framework (v 1.16), the issue was related to the plugin registry for the new Android embeddings introduced in later versions. But this situation forced us to think outside the box, which is how we got around to introducing the TypeForm payment pathway which we attached to our website (which we are now beginning to phase out).

As a startup, you have to be able to think on your feet and get the job done. That’s one thing I always appreciated about my co-founder and I; although we may disagree on various topics, when we do come to a conclusion, we work until it’s finished. We’re both extremely results-orientated, which I believe is a big part of Cinebur’s success so far: the ability to execute on the task at hand, and get the job done.

Until next time,

Adrian Coutsoftides

Co-founder & CTO at Cinebur

Let us know if you find these articles helpful in the comments! If there’s a topic you’d like us to cover in Cinebur Tech, we’d love to hear from you.

Check out our next article on RecoilJS + React + Firestore for some more code examples and a simple introduction to React’s new state management library:

--

--