Kohei Asai

Kohei Asai

Written on 11/7/2019

Launched an app for Texas Hold'em Poker made of Flutter!

I launched iOS/Android apps made of Flutter to app stores for the first time. It's a tool to calculate win rates for each hands or hand ranges up to 10 players.

Download

Get it on Google Play Download on the App Store

This app is open source. You can refer the code from here. It would be really grateful if you leave a review at the app stores or star in the GitHub repository.

Implementation

Calculation process is just Monte Carlo method, which is trying randomly certain times and get average of that. In the real poker game, players guess what kind of cards the opponents have. This application is for such situation, so it's really impossible to calculate all possibilities because the time complexity will be O(n^m) at least.

Even the calculation in Monte Carlo method takes a lot of computation resource. You cannot do it in UI thread. So what I do is spawn a thread for calculation that communicates with UI thread. Flutter (if anything, Dart) has Isolate, which is an abstract API for multi threading/processing. This app uses that.

Did it hard to launch Flutter app?

No. But I recommend you to have experience of both of iOS and Android development. Coding part is well-wrapped by Flutter, therefore, you don't need any knowledge about Java, Swift, Xcode, Android and something like that. But in order to submit the app to the app stores, you will need to know about signing the app with a certification, minifying the app, building the app for each architecture of devices.

Multithreading

Isolate is really easy to use. As long as you want to do some simple multithreading, you will suffer from nothing. Isolate has some restriction in good way, so that it is on safe and simple API, also stands as guideline like as Golang's Goroutine.

Animation

Flutter supports sequence animations and tween animations.

I didn't implement so complicated animation, but I feel animation in Flutter is much easier and more familiar than DOM's. Because Flutter's rendering is high performance and any property of UI is able to be used in animation.

Dark mode

Flutter has MediaQuery API, which enables to obtain device information and OS settings such as:

  • Display metrics and orientation
  • Whether bold fonts are preferred (iOS)
  • Whether 24-hour time format is used

Flutter has InheritedWidget that is same propagation model with React's context. MediaQuery is on that. So you really easily can apply dark mode depending on users' OS setting to UI.

Aqua Light Theme Aqua Dark Theme

What Flutter isn't good for?

Using ads

Flutter doesn't use platform's original UI framework at all. Instead of that, Flutter mounts a canvas to entire the screen and renders UI with its own rendering system. Therefore, sometimes Flutter's rendering performance exceeds native's one. However, as for ads, it's not really good with Flutter because usually they serves a SDK that is implemented on native UI framework.

Using camera

Camera is also in the same situation. If you want to make camera apps such as Instagram or Snapchat, it's also quite hard. Because Flutter doesn't support camera by itself. In order to use camera, you'll call native API and it will rendered on native UI framework.