simple_native 0.0.8 copy "simple_native: ^0.0.8" to clipboard
simple_native: ^0.0.8 copied to clipboard

A comprehensive Flutter plugin for accessing native device features including Camera, Location, and Device Information.

simple_native #

A comprehensive Flutter plugin for accessing native device features including Camera, Location, and Device Information.

Features #

  • Camera:
    • Display a camera preview using SimpleCameraView.
    • Capture images.
    • Support for real-time image streaming (e.g., for image processing).
    • Configurable camera types (Image, QR Code, Stream).
    • Selectable Camera Position: Choose between front or back camera on initialization.
    • Locked Portrait Orientation: The camera view is locked to portrait mode to ensure consistent preview orientation.
    • Image Conversion: Built-in support for converting camera images (NV21/BGRA8888) to BMP format for display via SimpleCameraImage.toImage().
  • Location:
    • Get the current device location (latitude, longitude).
  • Device Information:
    • Retrieve basic device information (OS version, device model, etc.).
  • Platform Version:
    • Get the current platform version.

Getting Started #

Add simple_native as a dependency in your pubspec.yaml file.

dependencies:
  simple_native: ^0.0.8

Usage #

1. Camera #

Use SimpleCameraView to display the camera preview.

import 'package:simple_native/simple_native.dart';

// ...

SimpleCameraController? _controller;

SimpleCameraView(
  cameraType: SimpleCameraType.image, // or SimpleCameraType.qr, SimpleCameraType.stream
  cameraPosition: SimpleCameraPosition.back, // or SimpleCameraPosition.front
  onCameraCreated: (controller) {
    _controller = controller;
    
    // Example: Listen to image stream if cameraType is stream
    // controller.onImageStream((image) {
    //   print("Received image frame: ${image.width}x${image.height}");
    //   
    //   // Convert to BMP for display if needed
    //   // final bmpBytes = image.toImage();
    // });
  },
  onResult: (result) {
    // Handle camera result (e.g., QR code value)
    if (result.type == SimpleCameraResultType.qr) {
        print("QR Code: ${result.value}");
    }
  },
)

// ...

// To take a picture:
// final String? imagePath = await _controller?.takePicture();
// if (imagePath != null) {
//   print("Image captured at: $imagePath");
// }

// To switch camera:
// await _controller?.switchCamera();

// To resume scanning (after a QR code is detected):
// await _controller?.resumeScanning();

2. Location #

Get the current location.

import 'package:simple_native/simple_native.dart';

// ...

final simpleNative = SimpleNative();
final location = await simpleNative.getCurrentLocation();

if (location != null) {
  print("Latitude: ${location.latitude}, Longitude: ${location.longitude}");
}

3. Device Information #

Get device information.

import 'package:simple_native/simple_native.dart';

// ...

final simpleNative = SimpleNative();
final deviceInfo = await simpleNative.getDeviceInfo();

if (deviceInfo != null) {
  print("Device: ${deviceInfo.model}, OS: ${deviceInfo.osVersion}");
}

Platform Support #

Feature Android iOS
Camera
Location
Device Info

Installation #

Ensure you have the necessary permissions configured in your Android and iOS projects.

Android (AndroidManifest.xml):

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

iOS (Info.plist):

<key>NSCameraUsageDescription</key>
<string>Need camera access to take pictures.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Need location access to show current location.</string>

License #

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

3
likes
150
points
346
downloads

Publisher

verified publishertranduc1710.com

Weekly Downloads

A comprehensive Flutter plugin for accessing native device features including Camera, Location, and Device Information.

Homepage

Topics

#camera #location #device-info #native #plugin

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on simple_native

Packages that implement simple_native