ChangJoo-Park / platform_views_camera

Companion repository for the Platform Views blog post and presentation

Home Page:https://roszkowski.dev/platform-views

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NativeCameraView

An example of Flutter Platform View plugin that works as a camera preview and capture.

Android iOS macOS
android screenshot ios screenshot macos screenshot

This sample has been presented during Flutter Vikings 2022 conference in Oslo.

If you'd like to learn more about Flutter, feel free to follow me here.

Getting Started

Make sure to use a recent master version of Flutter (e.g. 3.5.0-10.0.pre.36).

I recommend opening the whole workspace in VS Code by calling:

code .

You will see the following directories:

  • example - our application
  • camera_view - federated plugin
    • camera_view - Dart implementation of the interface and widgets
    • camera_view_platform_interface - a common platform interface for the camera_view plugin
    • camera_view_xxx - platform implementations of the plugin

Try it out by running the example app on your desired device (iOS, Android, or macOS). There's VS Code launch configuration available.

Camera details

This sample hosts camera previews on the following platforms:

Platform Support
iOS Yes
Android Yes
macOS Yes
Windows No
Linux No
Web No

The iOS and macOS implementations use SwiftUI camera views from this article by Yono Mittlefehldt. The license note is included in every file copied from the original implementation.

The Android implementation uses CameraView library, which worked perfectly fine for this sample.

Known issues

  • macOS platform views don't handle gestures, throw exceptions when tapping anywhere even when ignoring touch events
  • macOS platform views cannot be shown beneath the Flutter widgets thus there's not way to draw UI on top of the platform view
  • window resizing on macOS is broken due to this threading issue

Contributing

Contributions are welcome! If you'd like to improve existing implementation or propose new platform to be supported, please go ahead!

About

Companion repository for the Platform Views blog post and presentation

https://roszkowski.dev/platform-views

License:MIT License


Languages

Language:Swift 40.5%Language:Dart 20.8%Language:C++ 15.6%Language:CMake 12.0%Language:Kotlin 5.6%Language:Ruby 2.5%Language:C 1.6%Language:HTML 1.1%Language:Objective-C 0.4%