Skip to content

A camera picker (take photos and videos) for Flutter projects based on WeChat's UI. It's a standalone module of wechat_assets_picker yet it can be run separately.

License

Notifications You must be signed in to change notification settings

fredrik-smedberg/flutter_wechat_camera_picker

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Flutter WeChat Camera Picker

pub package pub package CodeFactor

Build status GitHub license GitHub stars GitHub forks

Flutter Candies QQ็พค

Language: English | ไธญๆ–‡

A camera picker for Flutter projects based on WeChat's UI, which is also a separate runnable extension to the wechat_assets_picker.

Current WeChat version that UI based on: 8.3.x UI designs will be updated following the WeChat update in anytime.

See the Migration Guide to learn how to migrate between breaking changes.

Package credits

The package is built from these wonderful packages.

Name Features
photo_manager The basic abstractions and management for assets.
camera Captures images and videos.
video_player Plays videos and audios correspondingly.

Their implementation should be relatively stable in the package. If you've found any issues related to them when using the picker, submit issues to our issue tracker first.

Table of content

Features โœจ

  • โ™ฟ Complete a11y support with TalkBack and VoiceOver
  • โ™ป๏ธ Fully implementable with States override
  • ๐ŸŽ Fully customizable theme based on ThemeData
  • ๐Ÿ’š Completely WeChat style (even more)
  • โšก๏ธ Adjustable performance with different configurations
  • ๐Ÿ“ท 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
  • ๐Ÿ–พ Foreground custom widget builder support
  • ๐Ÿ•น๏ธ Intercept saving with custom process

Screenshots ๐Ÿ“ธ

READ THIS FIRST โ€ผ๏ธ

Be aware of below notices before you started anything:

  • Due to understanding differences and the limitation of a single document, documents will not cover all the contents. If you find nothing related to your expected features and cannot understand about concepts, run the example project and check every options first. It has covered 90% of regular requests with the package.
  • The package deeply integrates with the photo_manager plugin, make sure you understand these two concepts as much as possible:

When you have questions about related APIs and behaviors, check photo_manager's API docs for more details.

Most usages are detailed covered by the example. Please walk through the example carefully before you have any questions.

Preparing for use ๐Ÿญ

Versions compatibility

The package only guarantees to be working on the stable version of Flutter. We won't update it in real-time to align with other channels of Flutter.

2.8.0 3.3.0
4.0.0+ โŒ โœ…
3.0.0+ โœ… โŒ

If you got a resolve conflict error when running flutter pub get, please use dependency_overrides to fix it.

Setup

Run flutter pub add wechat_camera_picker, or add wechat_camera_picker to pubspec.yaml dependencies manually.

dependencies:
  wechat_camera_picker: ^latest_version

The latest stable version is: pub package

The latest dev version is: pub package

Follow these detailed setup guide before runs:

Then import the package in your code:

import 'package:wechat_camera_picker/wechat_camera_picker.dart';

Usage ๐Ÿ“–

Localizations

When you're picking assets, the package will obtain the Locale? from your BuildContext, and return the corresponding text delegate of the current language. Make sure you have a valid Locale in your widget tree that can be accessed from the BuildContext. Otherwise, the default Chinese delegate will be used.

Embedded text delegates languages are:

  • ็ฎ€ไฝ“ไธญๆ–‡ (default)
  • English
  • Tiแบฟng Viแป‡t

If you want to use a custom/fixed text delegate, pass it through the CameraPickerConfig.textDelegate.

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 States

All user interface can be customized through custom States, including:

  • CameraPickerState
  • CameraPickerViewerState

After override States, 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: flutter/flutter#89216 . Other than that, please submit issues to describe your question.

Contributors โœจ

Thank goes to these wonderful people (emoji key):

Alex Li
Alex Li

๐Ÿ’ป ๐ŸŽจ ๐Ÿ“– ๐Ÿ’ก ๐Ÿค” ๐Ÿšง ๐Ÿ’ฌ ๐Ÿ‘€
Caijinglong
Caijinglong

๐Ÿ’ก ๐Ÿค”
Lael
Lael

๐Ÿ“–
mjl0602
mjl0602

๐Ÿ’ป ๐Ÿค”
AliasWang
AliasWang

๐Ÿ’ป ๐Ÿค”
leftcoding
leftcoding

๐Ÿ›
Luong The Vinh
Luong The Vinh

๐Ÿ’ป
luomo-pro
luomo-pro

๏ธ๏ธ๏ธ๏ธโ™ฟ๏ธ ๐Ÿ›
LeonardoZhu
LeonardoZhu

๐Ÿ’ป
Nguyen Phuc Loi
Nguyen Phuc Loi

๐ŸŒ

This project follows the all-contributors specification. Contributions of any kind welcome!

About

A camera picker (take photos and videos) for Flutter projects based on WeChat's UI. It's a standalone module of wechat_assets_picker yet it can be run separately.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 98.8%
  • Other 1.2%