simple_native 0.0.4
simple_native: ^0.0.4 copied to clipboard
Du an ve cac tinh nang co ban ve native cho Flutter
simple_native #
A Flutter plugin that provides access to basic native features such as 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, Video - Video support coming soon).
- Locked Portrait Orientation: The camera view is locked to portrait mode to ensure consistent preview orientation.
- Display a camera preview using
- 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.1
Usage #
1. Camera #
Use SimpleCameraView to display the camera preview.
import 'package:simple_native/simple_native.dart';
// ...
SimpleCameraView(
cameraType: SimpleCameraType.image,
onCameraCreated: (controller) {
// You can use the controller to interact with the camera
// e.g., controller.startImageStream((image) { ... });
},
onResult: (result) {
// Handle camera result (e.g., captured image path)
print("Image captured: ${result.filePath}");
},
)
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.