Case Study: Flutter Development

Published by SNNAFI on

I have always liked the native way of developing apps. But, I am now learning flutter. Actually, I tried flutter back in 2019, but I left it after a few months and started native again. At the same time, I have started learning native iOS development. So, I have now experience in both android and iOS native. And I think this is the perfect time to learn flutter. You can ask me why? Let me share my recent experience with flutter development!

I have been developing an android app for a year. It is mainly a content-based app. But it has a little complexity in some ways. Actually, this is the reason for writing this post. So, after developing for a year, I was then planning to develop an iOS version also as well as I needed to heavily refactor my previous structure in the android app. So, I think I should give flutter a try for this. A win-win situation in both ways. Learning and developing at the same time. AND, yes I have learned something good.

So, I have developed the application in flutter. But I was not able to find anything near to SpannableString(Android) in flutter. In iOS, it is NSAttributedstring . Flutter has RichText but it is no match to the elders.

My requirement was to find all arabic characters in a string and add a click handler to them for tts, color them and add different font. After a lot of tests and trials, I have somehow managed it.

BUT, the real problem is in its chilling mode! In flutter, it is NOT possible to align two different types of language ( i.e LTR, RTL ) in the same rich text widget !. I have had no solution for this until now. It turns out, I need to develop a custom widget for that. This is overkill for me in the current situation.

So, I have chosen a different approach. My 90% function was okay in flutter. Just only one screen i.e. the content detail page. So, I have developed them separately for android and iOS.

In the android part, I have added activity and used FlutterMethodChannel to pass data from flutter to native activity and start the activity. It works perfectly with flutter.

In the iOS part, there were a few approaches. As the root view controller is FlutterViewController, I have to keep the original reference of it. But we could not push another view controller without a UINavigationController.. We could present it without a UINavigationController. BUT it is not a good user experience as it will be shown as a modal. I could also add the new view controller as a subview but, I thought this was not also a good approach.So, I have chosen the UINavigationController. way. Wrapped the FlutterViewController in a UINavigationController and push the new view controller. Then used FlutterMethodChannel for the rest.

Thanks to Hamza vai for helping me fix a bug in the iOS part. I was using writingDirection for NSAttributedString but the correct approach is to use paragraphStyle for showing RTL and LTR text in the same UITextView.

So, in this way, I have saved a lot of time developing the application in flutter. But I have needed to write native code also as there are some complex scenarios in which native is the only way to do it.

So, my final thought about flutter is, It is good to learn flutter and develop apps in flutter. BUT, we also need to have some knowledge in native. It will help us develop complex apps and at the same time faster. In my case, my app is written 90% in flutter and 10% in native.

If I have you here, thank you for reading this boring post. And please share your thoughts about it.


0 Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.