패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.2.1

ambient_light

Android, iOS 및 macOS에서 환경광 센서 데이터에 액세스할 수 있는 강력한 플러그인

AndroidiOSmacOSWindowsLinux
30일 다운로드
1.9천
좋아요
21
Pub 점수
160

패키지 설치

flutter pub add ambient_light

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

ambient_light 패키지는 안드로이드, iOS, macOS, Windows 및 리눅스에서 환경광 센서 데이터에 액세스하기 위한 크로스플랫폼 솔루션을 제공합니다. 이는 애플리케이션이 주변 조도 수준을 감지할 수 있게 하여 자동 밝기 조절이나 적응형 디스플레이 설정과 같은 동적 UI 조정을 가능하게 합니다. 플러터 앱과 원활하게 통합되는 가벼운 플러그인으로, 스트림을 통해 실시간 센서 업데이트를 제공합니다. 사용 가능한 경우 전경 및 백그라운드 작동을 모두 지원하여 에너지 효율적이고 맥락 인식 기능을 갖춘 애플리케이션에 이상적입니다.

사용 사례

  • 자동 밝기 조정
  • 에너지 절약 표시 모드
  • 컨텍스트 인식 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

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.