HomeSDK IntegrationDiscussions
Log In
SDK Integration

Flutter Walkthrough

Introduction

This page acts as dedicated support for integrating the Captur SDK into a Flutter application.

Many of the principles from the iOS and Android walkthroughs apply here as well.

Native Camera Implementation

The SDK can use both the default camera and 'Ultrawide' camera on supported devices.

Using the reference implementation captur-micromobility-demo, we can highlight how to call both cameras for Android and iOS.

iOS

The below example provides a basic implementation of the two camera modes.

import CapturMicromobilityEvents

// Default camera flow
struct VerificationScreen: View {
    @Environment(\.presentationMode) var presentationMode
    @EnvironmentObject var verificationViewModel: VerificationViewModel
    @State var isFlashOn: Bool = false
    @State var isZoomedIn: Bool = false
    
    var body: some View {
        ZStack {
          CapturCamera(
            capturCameraHandler: verificationViewModel.manager, 
            isFlashOn: $isFlashOn, 
            isZoomedIn: $isZoomedIn
          )
        }
    }
}

// Ultrawide camera flow
struct VerificationScreen: View {
    @Environment(\.presentationMode) var presentationMode
    @EnvironmentObject var verificationViewModel: VerificationViewModel
    @State var isFlashOn: Bool = false
    
    var body: some View {
        ZStack {
          CapturUltraWideCamera(
            capturCameraHandler: verificationViewModel.manager, 
            isFlashOn: $isFlashOn
          )
        }
    }
}

Android

The implementation for Android is similar to iOS but with a new parameter 'ultraWideState'.

import com.captur.capturmicromobility.camera.CapturCameraPreview
import com.captur.capturmicromobility.camera.CapturUltraWideCamera

// Default camera preview
verificationViewModel.capturCameraManager.let {
    CapturCameraPreview(
      system = it,
      flashLightOn = isFlashOn, // Bool: Toggle to enable/disable flash
      zoomState = isZoomedIn,   // Bool: Toggle to enable/disable zoom
    )
}

// Ultrawide camera preview
verificationViewModel.capturCameraManager.let {
     CapturUltraWideCamera(
       system = it,
       flashLightOn = isFlashOn,     // Bool: Toggle to enable/disable flash
       ultraWideState = isUltraWide  // Bool: Enable ultrawide camera on supported devices
     )
}