Flutter WeChat Camera Picker
Language: English | 䏿įŽäŊ
A camera picker based on WeChat's UI which is a separate runnable extension to
wechat_assets_picker.
The package based on camera
for camera functions
and photo_manager
for asset implementation.
Category đ
Features â¨
- âģī¸ Fully implementable with
State
s override - đ 99% similar to WeChat style
- đˇ Picture taking support
- đĨ Video recording support
- âą Duration limitation support
- đ Scale when recording support
- âī¸ Exposure adjust support
- đī¸ Scale with pinch support
- đą i18n support
- âĒ RTL language support
- đ Fully customizable theme
- đž Foreground custom widget builder support
- đšī¸ Intercept saving with custom process
Screenshots đ¸
![]() |
![]() |
---|---|
![]() |
![]() |
Preparing for use đ
Version constraints
Flutter SDK: >=2.8.0
.
Setup
Android 13 (API 33) permissions
If you don't need to take photos or videos, consider removing relevant permission in your apps, more specifically:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.your.app">
<!-- Add this if you need to take photos. -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<!-- Add this if you need to take videos. -->
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
</manifest>
Usage đ
Simple usage
final AssetEntity? entity = await CameraPicker.pickFromCamera(context);
With configurations
Use CameraPickerConfig
for more picking behaviors.
final AssetEntity? entity = await CameraPicker.pickFromCamera(
context,
pickerConfig: const CameraPickerConfig(),
);
Fields in CameraPickerConfig
:
Name | Type | Description | Default Value |
---|---|---|---|
enableRecording | bool |
Whether the picker can record video. | false |
onlyEnableRecording | bool |
Whether the picker can only record video. Only available when enableRecording is true . |
false |
enableTapRecording | bool |
Whether allow the record can start with single tap. Only available when enableRecording is true . |
false |
enableAudio | bool |
Whether Whether the picker should record audio. Only available with recording. | true |
enableSetExposure | bool |
Whether users can set the exposure point by tapping. | true |
enableExposureControlOnPoint | bool |
Whether users can adjust exposure according to the set point. | true |
enablePinchToZoom | bool |
Whether users can zoom the camera by pinch. | true |
enablePullToZoomInRecord | bool |
Whether users can zoom by pulling up when recording video. | true |
shouldDeletePreviewFile | bool |
Whether the preview file will be delete when pop. | false |
shouldAutoPreviewVideo | bool |
Whether the video should be played instantly in the preview. | false |
maximumRecordingDuration | Duration? |
The maximum duration of the video recording process. | const Duration(seconds: 15) |
minimumRecordingDuration | Duration |
The minimum duration of the video recording process. | const Duration(seconds: 1) |
theme | ThemeData? |
Theme data for the picker. | CameraPicker.themeData(wechatThemeColor) |
textDelegate | CameraPickerTextDelegate? |
Text delegate that controls text in widgets. | CameraPickerTextDelegate |
resolutionPreset | ResolutionPreset |
Present resolution for the camera. | ResolutionPreset.max |
cameraQuarterTurns | int |
The number of clockwise quarter turns the camera view should be rotated. | 0 |
imageFormatGroup | ImageFormatGroup |
Describes the output of the raw image format. | ImageFormatGroup.unknown |
preferredLensDirection | CameraLensDirection |
Which lens direction is preferred when first using the camera. | CameraLensDirection.back |
lockCaptureOrientation | DeviceOrientation? |
Whether the camera should be locked to the specific orientation during captures. | null |
foregroundBuilder | ForegroundBuilder? |
The foreground widget builder which will cover the whole camera preview. | null |
previewTransformBuilder | PreviewTransformBuilder? |
The widget builder which will transform the camera preview. | null |
onEntitySaving | EntitySaveCallback? |
The callback type define for saving entity in the viewer. | null |
onError | CameraErrorHandler? |
The error handler when any error occurred during the picking process. | null |
onXFileCaptured | XFileCapturedCallback? |
The callback type definition when the XFile is captured by the camera. | null |
onMinimumRecordDurationNotMet | VoidCallback? |
The callback when the recording is not met the minimum recording duration. | null |
Using custom State
s
All user interface can be customized through custom State
s, including:
CameraPickerState
CameraPickerViewerState
After override State
s, pass them through the picking method, more specifically:
CameraPicker.pickFromCamera(createPickerState: () => CustomCameraPickerState());
CameraPickerViewer.pushToViewer(..., createViewerState: () => CustomCameraPickerViewerState());
Frequently asked question đ
Why the orientation behavior is strange on iOS?
Currently, the preview is not correctly synced on the iOS. You can find more details in this issue: https://github.com/flutter/flutter/issues/89216 . Other than that, please submit issues to describe your question.
Contributors â¨
Thank goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!