パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.2.1

ambient_light

Android、iOS、macOSで環境光センサーのデータにアクセスするための強力なプラグイン

AndroidiOSmacOSWindowsLinux
30日間ダウンロード
1950
いいね数
21
Pub ポイント
160

パッケージをインストール

flutter pub add ambient_light

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

ambient_light パッケージは、Android、iOS、macOS、Windows、Linux で環境光センサーのデータにアクセスするためのクロスプラットフォームソリューションを提供します。アプリケーションが周囲の明るさを検出し、自動輝度調整や適応型ディスプレイ設定などのダイナミックなUI調整を可能にします。このプラグインは軽量でFlutterアプリとシームレスに統合され、ストリームを通じてリアルタイムのセンサーデータ更新を提供します。利用可能な場合、フォアグラウンドおよびバックグラウンドでの動作をサポートしており、エネルギー効率が高くコンテキストに応じたアプリケーションに最適です。

用途

  • 自動輝度調整
  • 省エネ表示モード
  • コンテキストに応じたUIデザイン
  • 環境モニタリングアプリ
  • スマート照明の統合

主な機能

  • リアルタイムの光レベルストリーミング
  • クロスプラットフォーム対応(Android、iOS、macOS、Windows、Linux)
  • ストリームベースの更新を備えたシンプルな API
  • 低消費電力
  • バックグラウンドセンサーへのアクセス

適している対象

  • 環境認識を必要とするアプリ
  • アクセシビリティ機能
  • バッテリー最適化ツール
  • スマートホーム統合
  • ウェアラブル機器とモバイルアプリ

注意事項

  • センサーの利用可能性はデバイスのハードウェアに依存します
  • 一部のプラットフォームでの精度が制限されています
  • AndroidおよびiOSで適切な権限が必要です
  • すべての古いデバイスでサポートされていません
  • バックグラウンドでの使用は、OSポリシーによって制限される場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Ambient Light for iOS and android

Issues Issues GitHub Pull Requests GitHub GitHub Repo stars

A Flutter plugin to access ambient light sensor data on Android, iOS and macOS. This plugin allows you to retrieve the current ambient light level and listen to continuous updates.

Features

  • Android: Uses the SensorManager to access the device's ambient light sensor.
  • iOS: Uses CoreMotion to access the ambient light sensor data on compatible iOS devices.
  • macOS: Uses IOKit to access the ambient light sensor data on compatible macOS devices.
  • Retrieve Current Light Level: Get the current ambient light level as a single value.
  • Stream Light Level: Listen to continuous updates of the ambient light level.

Installation

To use this plugin, you can add it to your Flutter project in one of two ways:

1. Add to pubspec.yaml

Include the following dependency in your pubspec.yaml file:

dependencies:
  ambient_light: ^0.2.1
  
2. Add directly from the terminal

Run the following command to add the plugin directly to your project:

flutter pub add ambient_light

Usage

Import the package and use the provided methods to get ambient light sensor data.

import 'package:ambient_light/ambient_light.dart';

void main() async {
  final AmbientLight _ambientLight = AmbientLight(frontCamera: true);
  
  // Get ambient light value
  double? lightLevel = await _ambientLight.currentAmbientLight();
  print('Ambient light level: $lightLevel');

  // Listen to ambient light sensor data stream
  _ambientLight.ambientLightStream.listen((double lightLevel) {
    print('Ambient light level: $lightLevel');
  });
}

[!NOTE] Useful information that users should know, even when skimming content.

  • The frontCamera parameter is iOS only and allows you to specify whether to use the front or back camera for measuring ambient light. For other platforms, you can initialize with the default:
    final AmbientLight _ambientLight = AmbientLight();
    
  • Checkout Example for complete explanation

Methods

Future<double?> currentAmbientLight();

Returns the current ambient light level as a double. Returns null if the sensor is not available.

Stream<double> get ambientLightStream;

Returns a stream of ambient light sensor data as double.

iOS

For iOS, the plugin uses CoreMotion to access ambient light sensor data. You need to add the following key to your Info.plist to request access to the camera, which is required for measuring ambient light.


<key>NSCameraUsageDescription</key>
<string>We need access to the camera to measure ambient light.</string>

Contributions

Contributions are welcome! Please submit a pull request or open an issue to discuss any changes.

Licence

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

カテゴリー

依存関係

依存関係一覧 1 件

  • plugin_platform_interface^2.0.2

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。