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

GitHub 저장소craftsoft-dev/flutter_keep_screen_on

flutter_keep_screen_on

이 플러그인은 자동 화면 꺼짐을 비활성화하고 화면이 꺼지는 것을 방지합니다.

flutter_keep_screen_on 프로젝트 이미지
스타
13
포크
8
최근 푸시(UTC)
2026. 9. 5.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

KeepScreenOn

This plugin disables automatic screen off and prevents the screen from turning off.

Getting Started

Add this to your package's pubspec.yaml file:

dependencies:
  keep_screen_on: ^6.0.0

Usage

Import KeepScreenOn.

import 'package:keep_screen_on/keep_screen_on.dart';

To keep the screen from turning off, call the turnOn method of the KeepScreenOn class.

// Keep the screen on.
KeepScreenOn.turnOn();

Calling the turnOff method of the KeepScreenOn class will restore the screen to turn off automatically.
Alternatively, you can do the same by specifying false as the argument to the turnOn method.

// Reset
KeepScreenOn.turnOff();

// or...
KeepScreenOn.turnOn(on: false);

You can check if the screen is not turned off by checking the isOn property or isOff property.
Since isOn and isOff return Future <bool?>, you need to use "await" or receive the value with the "then" method.

Future<bool?> getScreenKeepOn() async {
  return await KeepScreenOn.isOn; 
}

Future<bool?> getScreenKeepOff() async {
  return await KeepScreenOn.isOff;
}
Android only.

The following functions are available on Android. Nothing happens even if you run it on an OS other than Android.

You can specify the withAllowLockWhileScreenOn argument to the turnOn and turnOff methods.
When withAllowLockWhileScreenOn: true is specified, FLAG_ALLOW_LOCK_WHILE_SCREEN_ON is also specified in addition to FLAG_KEEP_SCREEN_ON.

KeepScreenOn.turnOn(withAllowLockWhileScreenOn: true);

KeepScreenOn.turnOff(withAllowLockWhileScreenOn: true);

If you want to switch only FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, you can do so by calling the method below.

KeepScreenOn.addAllowLockWhileScreenOn();

KeepScreenOn.clearAllowLockWhileScreenOn();

You can check the assignment status of FLAG_ALLOW_LOCK_WHILE_SCREEN_ON from the isAllowLockWhileScreenOn property.

KeepScreenOn.isAllowLockWhileScreenOn

Each call returns the following values on non-Android OS:

Method/Property Returns
addAllowLockWhileScreenOn false
clearAllowLockWhileScreenOn false
isAllowLockWhileScreenOn null

Attention

When you call the turnOn method with no arguments or with on: true,
Android sets android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON for the activity window as an internal action.
iOS sets UIApplication.shared.isIdleTimerDisabled to true.

For this reason, be sure to use the dispose method of StatefulWidget etc.

KeepScreenOn.turnOff();

Should be called. If you forget to call turnOff (or turnOn(on: false)), the screen will not turn off automatically while the app is running.

For Android, when the activity is switched, the automatic screen off will follow the activity to which it was switched.
For iOS, automatic screen off is restored when you move to the background.

craftsoft-dev GitHub avatar
GitHub 작성자

craftsoft-dev ↗

언어DartKotlinSwiftRubyObjective-C

이 저장소가 배포한 패키지

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

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

GitHub Docs — About repositories ↗