搜尋分類、套件與程式碼儲存庫

GitHub 儲存庫Destiny-Ed/flutter_camera

flutter_camera

適用於 iOS 和 Android 的 Flutter 插件,可存取裝置相機並錄製影片

flutter_camera 專案封面
星標
5
分支
6
最近推送(UTC)
2023年8月14日
專案狀態
未封存

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

Flutter Camera

pub package

A Flutter plugin for iOS and Android allowing access to the device cameras and recording of videos.

Note: This plugin is still under development, and some APIs might not be available yet. We are working on a refactor which can be followed here: issue

This package fully depends on flutter camera plugin to provide access to camera.

It only supports Android and IOS for now

Features

  • Display live camera preview in a widget.
  • Snapshots can be captured and path is returned.
  • Device flash light support.
  • Record video from camera.
  • Add access to the image stream from Dart.
  • Live camera flip ( switch between rear & front camera with a click ).
  • Only 3 lines of code

Installation

First, add flutter_camera as a dependency in your pubspec.yaml file.

iOS

The camera plugin functionality works on iOS 10.0 or higher. If compiling for any version lower than 10.0, make sure to programmatically check the version of iOS running on the device before using any camera plugin features. The device_info_plus plugin, for example, can be used to check the iOS version.

Add two rows to the ios/Runner/Info.plist:

  • one with the key Privacy - Camera Usage Description and a usage description.
  • and one with the key Privacy - Microphone Usage Description and a usage description.

Or in text format add the key:

<key>NSCameraUsageDescription</key>
<string>Can I use the camera please?</string>
<key>NSMicrophoneUsageDescription</key>
<string>Can I use the mic please?</string>
Android

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21
Example

Here is a small example flutter app displaying a full screen camera preview with video recording.

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_camera/flutter_camera.dart';

class CameraPage extends StatefulWidget {
  const CameraPage({Key? key}) : super(key: key);

  @override
  _CameraPageState createState() => _CameraPageState();
}

class _CameraPageState extends State<CameraPage> {
  @override
  Widget build(BuildContext context) {
    return FlutterCamera(
      color: Colors.amber,
      onImageCaptured: (value) {
        final path = value.path;
        print("::::::::::::::::::::::::::::::::: $path");
        if (path.contains('.jpg')) {
          showDialog(
              context: context,
              builder: (context) {
                return AlertDialog(
                  content: Image.file(File(path)),
                );
              });
        }
      },
      onVideoRecorded: (value) {
        final path = value.path;
        print('::::::::::::::::::::::::;; dkdkkd $path');
        ///Show video preview .mp4
      },
    );
    // return Container();
  }
}

Destiny Ed GitHub avatar
GitHub 作者

Destiny Ed ↗

Senior Flutter Engineer • Mobile & Product Engineer

語言Dart

此儲存庫發佈的套件

使用的依賴

依賴清單 4 項

  • flutter{"sdk":"flutter"}
  • camera^0.10.5+3
  • flutter_test開發依賴{"sdk":"flutter"}
  • flutter_lints開發依賴^1.0.0

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗