Using Flutter for cross-platform video application development
Tags: flutter, mobile, webrtc, dart
Published: 2023-07-21 20:16:47

_By [Thomas Järvstrand](https://www.daily.co/blog/author/thomas-jarvstrand/), [Liza Shulyayeva](https://www.daily.co/blog/author/liza/)_

Flutter, developed by Google, is a powerful cross-platform app development framework that has gained significant popularity in recent years.

In this blog post, I will go through Flutter’s core components, its programming language (Dart), and the concept of widgets. I’ll also discuss why Flutter has become a preferred choice for many companies and why we care about it at Daily.

## What is Flutter?
Flutter is a cross-platform app development framework designed by Google. It enables developers to build high-quality applications for various platforms, including iOS, Android, Windows, MacOS, Linux, and the web.

Flutter’s flexibility and compatibility continue to expand, with upcoming support for [WebAssembly (WASM)](https://webassembly.org/) and [RISC-V](https://riscv.org/). With recent advancements in compiling Dart code directly to WASM, Flutter’s potential for web development is set to increase further.

Both Flutter and Dart are open source, so even though they currently enjoy a lot of support and investment from Google, they aren’t contingent on Google’s ongoing commitment. Which, considering Google’s track record with its products, is pretty comforting...

## What Daily is doing with Flutter
Daily’s developing a Flutter SDK, which is currently in pre-Beta stage. Like our native mobile SDKs, it is built on top of our Rust-based cross-platform core. This post will focus more on Flutter itself and not so much our SDK for it, but if you have a Flutter use case and would like to get an early preview of the SDK, just [reach out to our support team](https://www.daily.co/company/contact/support/).

## Advantages of using Flutter
Flutter is built on three core values that drive the direction of it development:

- It must be fast
- It must be developer friendly
- It must be easy to learn

### It must be fast: Near-native performance
Flutter offers near-native performance by compiling code to native machine code on platforms like iOS and Android. For web applications, it uses its rendering engine to bypass the Document Object Model (DOM) and render elements on an HTML5 canvas. It’s very efficient at calculating which parts of the UI have been updated and need to be redrawn.

### It must be developer friendly: Great tooling
Flutter provides a range of features to enhance developer productivity. Its hot reload and hot restart capabilities enable rapid development and experimentation by quickly reflecting code changes in the running app. Additionally, Flutter offers extensive tooling, including performance analysis, debugging, and automated testing facilities.

### It must be easy to learn: Low barrier to entry
Compared to other cross-platform frameworks, Flutter is relatively easy to learn and get started with. Its comprehensive documentation, runnable examples, and intuitive syntax make it accessible for developers of all backgrounds. Dart, the programming language used in Flutter, is designed to be familiar and offers a C-style syntax.

### Large widget library
Flutter offers an extensive collection of prebuilt widgets that developers can leverage to enhance their app’s functionality and appearance. These widgets adhere to both the Material Design guidelines (Google’s design language) and the Cupertino style (Apple’s design language).

## Dart: The language of Flutter
Flutter utilizes the Dart programming language, which offers several features that contribute to a smooth development experience:

### Familiar syntax
Dart’s C-style syntax and intuitive structure make it approachable for developers. Google specifically designed Dart to be easy to understand, reducing complexity and encouraging code readability. Dart is object-oriented, garbage collected, and type safe (optionally… but that’s a topic for another day.)

### Great docs
Dart’s [documentation](https://dart.dev/guides) and [runnable examples](https://github.com/dart-lang/samples) provide comprehensive resources for learning and experimentation. The ability to run examples directly in the browser allows developers to observe the effects of different changes on widgets.

### Memory safety and concurrency
In Dart’s **_Native platform_**, all code runs in an **_isolate_**. Isolates are a little like threads, but each isolate has its own heap and event loop. The only way isolates can communicate with each other is through message passing. This avoids issues with concurrent access, or variables being changed out from under you during execution.

For Dart’s **_Web platform_**, apps can run background scripts in web workers, similarly to isolates. They won’t be quite as fast as isolates on native, but can accomplish the same goals.

## Using Flutter for video and audio applications
A video view in Flutter relies on a [`Texture`](https://api.flutter.dev/flutter/widgets/Texture-class.html) widget provided by Flutter. The actual rendering happens in Flutter’s [platform layer](https://docs.flutter.dev/resources/architectural-overview#rendering-and-layout).

In the case of Daily, developers create a [`VideoView`](https://pub.dev/documentation/daily_flutter/latest/daily_flutter/VideoView-class.html), which in turn sets up a `Texture` widget with a unique ID. When we want the `VideoView` to show the video of a call participant, we send a message to the platform layer, which then grabs the corresponding WebRTC video track and connects its stream with the Flutter texture registry.

## Why does Daily care about Flutter?
Flutter has gained significant market share, with over 700,000 Flutter apps already available on the Google Play Store according to Google. Noteworthy organizations are using Flutter, such as:

- Ubuntu (installer written in Flutter)
- Google Pay (entirely written in Flutter)
- Toyota (writing all their infotainment systems in Flutter)

Flutter’s popularity has surpassed React Native in terms of Stack Overflow questions and Google searches. Its upward trajectory suggests a promising future, so we’re really excited to support Flutter developers building video applications.

## Conclusion
In this post, we’ve covered what Flutter is, why it’s great, and why we care about it. If you have any questions or comments, or are already building something cool with Flutter, please head over to [our WebRTC community](https://community.daily.co/) to keep the conversation going. And if you’d like to check out our (pre-Beta) Flutter SDK, reach out to [our support team](https://www.daily.co/company/contact/support/) for more information.