creativecreatorormaybenot
Committed by GitHub

Integrate wakelock_windows into wakelock (#101)

* Integrate wakelock_windows into wakelock

* Fix wakelock_web
# Wakelock [![GitHub stars](https://img.shields.io/github/stars/creativecreatorormaybenot/wakelock.svg)](https://github.com/creativecreatorormaybenot/wakelock) [![Pub version](https://img.shields.io/pub/v/wakelock.svg)](https://pub.dev/packages/wakelock) [![Twitter Follow](https://img.shields.io/twitter/follow/creativemaybeno?label=Follow&style=social)](https://twitter.com/creativemaybeno)
Wakelock is Flutter plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping.
Wakelock is Flutter plugin that allows you to keep the device screen awake, i.e. prevent the screen
from sleeping.
## Supported platforms
... ... @@ -10,7 +11,7 @@ Wakelock is Flutter plugin that allows you to keep the device screen awake, i.e.
| iOS | ✅ |
| Web | ✅ |
| macOS | ✅ |
| Windows | planned |
| Windows | |
| Linux | planned |
## Getting started
... ... @@ -32,6 +33,7 @@ The packages in this repo are the following:
| [`wakelock_macos`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_macos) | macOS implementation |
| [`wakelock_platform_interface`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface) | Basic API definition & message handling |
| [`wakelock_web`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_web) | Web implementation |
| [`wakelock_web`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_windows) | Windows implementation |
## Contributing
... ... @@ -40,7 +42,8 @@ If you want to contribute to this plugin, follow the [contributing guide](https:
## Origin
Originally, this plugin was based on [`screen`](https://pub.dev/packages/screen).
Specifically, the wakelock functionality was extracted into this plugin due to lack of maintenance by the author of the `screen` plugin.
Specifically, the wakelock functionality was extracted into this plugin due to lack of maintenance
by the author of the `screen` plugin.
Today, the `wakelock` plugin has been completely refreshed (using latest Flutter standards and platform integration) with added support
for web & macOS.
Today, the `wakelock` plugin has been completely refreshed (using latest Flutter standards and
platform integration) with added support for web, Windows, & macOS.
... ...
... ... @@ -2,4 +2,6 @@ include: package:pedantic/analysis_options.yaml
linter:
rules:
- public_member_api_docs
public_member_api_docs: true
# Ignoring unsafe_html as we need to import a JS script in wakelock_web and because of https://github.com/dart-lang/sdk/issues/45230.
unsafe_html: false
... ...
## 0.5.0
* Added Windows support 🚀
## 0.4.0
* Bumped to stable null safety release.
... ...
... ... @@ -15,7 +15,7 @@ Essentially, this allows you to keep the device awake, i.e. prevent the device f
| iOS | ✅ |
| Web | ✅ |
| macOS | ✅ |
| Windows | planned |
| Windows | |
| Linux | planned |
## Usage
... ...
... ... @@ -5,9 +5,9 @@
Pod::Spec.new do |s|
s.name = 'wakelock'
s.version = '0.0.1'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, and web.'
s.description = <<-DESC
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, and web.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
... ...
... ... @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:wakelock_macos/wakelock_macos.dart';
import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';
import 'package:wakelock_windows/wakelock_windows.dart';
/// The [WakelockPlatformInterface] that is used by [Wakelock].
///
... ... @@ -12,20 +13,33 @@ import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';
/// test the `pigeon` method channel implementation. Therefore, we want to
/// override this in tests that run on macOS (where there is no actual device).
@visibleForTesting
var wakelockPlatformInstance = !kIsWeb &&
// Assigning the macOS platform instance like this is not optimal.
// Ideally, we would use the default method channel instance on macOS,
// however, it is not yet entirely clear how to integrate with pigeon.
// This should just work fine and the io reference should be tree shaken
// on web.
Platform.isMacOS
? WakelockMacOS()
// This does not feel like the correct way to assign the Windows
// implementation, however, the platform channels do not have to be used
// thanks to the win32 package. See https://github.com/flutter/flutter/issues/52267.
// : (!kIsWeb && Platform.isWindows)
// ? WakelockWindows()
: WakelockPlatformInterface.instance;
var wakelockPlatformInstance = _defaultPlatformInstance;
/// Workaround for configuring platform instances until https://github.com/flutter/flutter/issues/52267
/// arrives on stable.
WakelockPlatformInterface get _defaultPlatformInstance {
// We want to return early on web as the platform checks are unsupported on
// web.
if (kIsWeb) return WakelockPlatformInterface.instance;
if (Platform.isMacOS) {
// Assigning the macOS platform instance like this is not optimal.
// Ideally, we would use the default method channel instance on macOS,
// however, it is not yet entirely clear how to integrate with pigeon.
// This should just work fine and the io reference should be tree shaken
// on web.
return WakelockMacOS();
}
if (Platform.isWindows) {
// This does not feel like the correct way to assign the Windows
// implementation, however, the platform channels do not have to be used
// thanks to the win32 package. See https://github.com/flutter/flutter/issues/52267.
return WakelockWindows();
}
return WakelockPlatformInterface.instance;
}
/// Class providing all wakelock functionality using static members.
///
... ...
... ... @@ -2,12 +2,12 @@ name: wakelock
description: >-2
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on
Android, iOS, macOS, Windows, and web.
version: 0.4.0
version: 0.5.0
homepage: https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock
environment:
sdk: '>=2.12.0-259.9.beta <3.0.0'
flutter: '>=1.24.0-0'
sdk: '>=2.12.0 <3.0.0'
flutter: '>=2.0.0'
dependencies:
flutter:
... ... @@ -16,7 +16,7 @@ dependencies:
meta: ^1.2.0
wakelock_macos: ^0.1.0
# wakelock_windows: ^0.1.0
wakelock_windows: ^0.1.0
wakelock_platform_interface: ^0.2.0
wakelock_web: ^0.2.0
... ... @@ -37,7 +37,7 @@ flutter:
pluginClass: WakelockPlugin
macos:
default_package: wakelock_macos
# windows:
# default_package: wakelock_windows
windows:
default_package: wakelock_windows
web:
default_package: wakelock_web
... ...
... ... @@ -4,9 +4,9 @@
Pod::Spec.new do |s|
s.name = 'wakelock_macos'
s.version = '0.0.1'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, and web.'
s.description = <<-DESC
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, and web.
DESC
s.homepage = 'https://github.com/creativecreatorormaybenot/wakelock/tree/master/packages/wakelock_macos'
s.license = { :type => 'BSD', :file => '../LICENSE' }
... ...