Skip to main content

Flutter : Awesome way for Hybrid Apps

Flutter is a cross-platform development framework made by Google to permit a single codebase for the two iOS and Android applications.

Flutter is Google’s free and open-source UI framework for creating native mobile applications. Released in 2017, Flutter allows developers to build mobile applications for both iOS and Android with a single codebase and programming language. This capability makes building iOS and Android apps simpler and faster.

The Flutter framework consists of both a software development kit (SDK) and their widget-based UI library. This library consists of various reusable UI elements, such as sliders, buttons, and text inputs.

Developers building mobile applications with the Flutter framework will do so using a programming language called Dart. With a syntax like JavaScript, Dart is a typed object programming language that focuses on front-end development.

My sample flutter web app : https://fir-example-6ce04.web.app/



Although Flutter is a newer cross-platform framework, more and more companies have chosen Flutter over frameworks such as Xamarin, Cordova, and React Native.

Some of the top reasons why development teams choose Flutter include:

  • Increased productivity. Using the same codebase for iOS and Android saves both time and resources. Flutter’s native widgets also minimize time spent on testing by ensuring there is little to no compatibility issues with different OS versions.
  • Easy to learn. Flutter allows developers to build native mobile applications without needing to access OEM widgets or use a lot of code. This, in addition to Flutter’s particularly appealing user interface, makes the mobile app creation process much simpler.
  • Great performance. Users report that it is difficult to notice the difference between a Flutter app and a native mobile app.
  • Cost-effective. Building iOS and Android apps with the same codebase is essentially building two apps for the price of one.
  • Available on different IDEs. Developers are free to choose between Android Studio and VS Code to edit their code on Flutter.
  • Great documentation & community. Flutter has many great resources to answer your questions, thanks to its ample documentation with easy-to-follow use cases. Flutter users also benefit from community hubs like Flutter Community and Flutter Awesome for exchanging ideas.


The Flutter framework presents exciting opportunities for mobile app developers and businesses alike. Building iOS and Android applications with the same codebase on a highly user-friendly interface makes mobile app development fast and cost-effective.

Flutter can communicate with Kotlin or Swift code through a messaging system called platform channels. The memory of the data in Dart is directly accessible to the platform embedder (as unique pointers and direct bytebuffers). A platform embedder (written in Objective C for iOS and Java for Android) is a component that contains the bridge code for communication between flutter engine and native platform apis. This communication does not add memory overhead.

Rendering

Unlike other frameworks, Flutter does not depend on Android or iOS ui libraries to render. Flutter uses Skia to render directly render on the GPU. Skia is a 2D graphics library that calls Metal/OpenGL apis to draw on iOS and Android. Skia apis are not exposed to us developers. We’ve to rely on flutter ui packages for custom painting. To benchmark performance, we ran heavy animations in Flutter, Android & iOS and found the fps rate similar to Android and slightly slow when compared to iOS. Flutter does not support HAL and frame pacing which are needed for game development. Flutter depends on the platform for 3D rendering, video playback and to capture frames from the camera. Flutter also does not have implementation like sqlite and depends the platform for all database requirements.




Isolates

Dart provides isolates for asynchronous jobs and unlike native threads, isolates do not share memory. Dart isolates have their own private heap, that are independent of each another. It’s hard to code a memory leak or data race conditions in Flutter when compared to Android. The communication between two isolates or with main UI isolate happens through a messaging system similar to platform channel.

GC

Both Android and Flutter have similar garbage collection strategies. The framework is designed to allocate short lived objects (ui widgets) so that it works well with a generational GC. The restriction on isolate memory sharing makes it easier to track the heap and when GC is running on one isolate it would not pause another isolate. The older generation objects are collected through concurrent Mark and Sweep strategy and the new generation is collected through Cheney’s algorithm.

Flutter as independent component in Android Screen

Other companies (Alibaba, Bytedance) have tried fusing Flutter and Android, that is having Flutter view on one screen and native view on another/having both Flutter and Android components on the same screen. This involves creating multiple flutter engines. In myexperiment, I was able to paint sheet grid on a single view using 4 flutter engines. Engine to engine communication is similar to isolate-isolate communication. However engines are memory intensive and slows down app performance.

Compilation

Flutter performs JIT compilation for development builds. For release builds there is no compiler, interpreter shipped as part of the Dart VM. The app code written in dart is compiled into executable shared object files containing machine code. The final flutter apk/ipa contains our app code as .so files, engine, precompiled dart runtime (isolates, gc, dart io), dex files of our native libraries, the embedder which communicates with the platform. All these components adds 5–8mb to app size.

Follow me for more updates like this.

Thank you for reading, have a pleasing day !


Comments

Popular posts from this blog

Basics Of Ansible,A OpenSource Tech

What is Ansible? Ansible is simple open source IT engine which automates application deployment, intra service orchestration, cloud provisioning and many other IT tools. Ansible uses playbook to describe automation jobs, and playbook uses very simple language i.e.  YAML  (It’s a human-readable data serialization language & is commonly used for configuration files, but could be used in many applications where data is being stored)which is very easy for humans to understand, read and write. Hence the advantage is that even the IT infrastructure support guys can read and understand the playbook and debug if needed (YAML — It is in human readable form). Ansible is designed for multi-tier deployment. Ansible does not manage one system at time, it models IT infrastructure by describing all of your systems are interrelated. Ansible is completely agentless which means Ansible works by connecting your nodes through ssh(by default). But if you want other method for connection like K...

Need of Open Source ?

You have already got what is  Open Source  from previous blogs. The simple reason is that why to pay if we get is free. Lets take an example you spend lots of money to buy an windows genuine some of the people don’t buy the licence copy of it but they buy an creak (DOS) version of windows but they have some problem in it. Some what same not a completely different OS are freely available in market then why should we pay for it ? You get high quality of software and hardware also in open source. They are very powerful and smooth running no lags get while working.They also give full support to solve your problem.Think an example of google you search on google and you get the result of what you search if google say that I want money for every search results then ?you will pay for it ? That the need of  open source .

CRM, a vast ocean of code I saw

  https://crm.zoho.com/ Head over to the Zoho CRM and see for yourself, well for the first time you will not feel it but as you go deep in it, you will realise the small small things that this CRM has implemented then you will get amazed by this amazing product. As a programmer, I got the chance to look at the vast ocean of code of this ZOHO CRM and experience like I was swimming in the ocean not knowing which way goes to where , I mean literally I was amazed how it has expanded,how it created little little things for its customers, the feeling of debugging it was on another level. I am grateful for the opportunity given by ZOHO to me for working in such a vast product. This CRM that I worked in won many awards, it had gone into Paul Greenberg’s (PG) CRM Watchlist 2022 award against major players like Adobe, Microsoft, Oracle, SAP, Salesforce, and ServiceNow with the highest score and distinction , PCMag.com awards “Business Choice Awards 2019” to Zoho CRM, beating 4 times winner —...