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...

Foreman,A Open Source Project

  1. What is Foreman? Foreman is an open source project that helps system administrators manage servers throughout their lifecycle, from provisioning and configuration to orchestration and monitoring. Using Puppet, Chef, Salt, Ansible and Foreman’s smart proxy architecture, you can easily automate repetitive tasks, quickly deploy applications, and proactively manage change, both on-premise with VMs and bare-metal or in the cloud. Foreman provide comprehensive, interaction facilities including a web frontend, CLI and RESTful API which enables you to build higher level business logic on top of a solid foundation. The Foreman interface is very easy to use and user friendly. As your organization grows, so does your workload — and the IT resources required to manage it. There is no “one-size-fits-all” system management solution, but a centralized, open source tool such as  Foreman  can help you manage your company’s IT assets by provisioning, maintaining, and updating hosts th...

Web Development the Beginning…

  As I mentioned in my latest gift(blog) that  web-development  can be done with the help of many tools such as, 1)  Node.js – open source, runtime environment for developing Web apps 2) AngularJs  — structural framework for dynamic Web apps 3)  Brackets  — a modern, open source text editor 4) Bootstrap  — Javascript framework for developing responsive Web apps 5) LESS  — the dynamic stylesheet language 6) Atom  — a text editor 7) Notepad ++  — a text editor To develop any web application, the things required are, 1) Code Editor  (Text Editor) 2) OS  (Operating System) and 3) Language  (in which we are coding) There are many  web-development   languages  but, the most  popular , easy to  code  and  dynamic  are , 1) HTML (Hypertext Markup Language) 2) CSS (Cascading Style Sheets) 3) XML (EXtensible Markup Language) 4) PHP (Hypertext Preprocessor) 5) SQL (Structured Query Languag...