creativecreatorormaybenot
Committed by GitHub

Fix null safety issues (#60)

* Fix null safety issues

* Adjust README
# Wakelock [![Publish workflow](https://github.com/creativecreatorormaybenot/wakelock/workflows/Publish/badge.svg)](https://github.com/creativecreatorormaybenot/wakelock/actions) [![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 [![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 on Android, iOS, and web.
... ...
## 0.2.0-nullsafety.1
* Fix null safety issues.
## 0.2.0-nullsafety.0
* Migrated to null safety.
## 0.1.0+1
* Updated messages with upgraded version of pigeon.
... ...
include: ../analysis_options.yaml
analyzer:
exclude:
- 'lib/messages.dart'
// Autogenerated from Pigeon (v0.1.14), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import
// @dart = 2.8
import 'dart:async';
import 'package:flutter/services.dart';
import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
import 'package:flutter/services.dart';
class ToggleMessage {
bool enable;
late bool enable;
// ignore: unused_element
Map<dynamic, dynamic> _toMap() {
final Map<dynamic, dynamic> pigeonMap = <dynamic, dynamic>{};
final pigeonMap = <dynamic, dynamic>{};
pigeonMap['enable'] = enable;
return pigeonMap;
}
// ignore: unused_element
static ToggleMessage _fromMap(Map<dynamic, dynamic> pigeonMap) {
final ToggleMessage result = ToggleMessage();
final result = ToggleMessage();
result.enable = pigeonMap['enable'];
return result;
}
}
class IsEnabledMessage {
bool enabled;
late bool enabled;
// ignore: unused_element
Map<dynamic, dynamic> _toMap() {
final Map<dynamic, dynamic> pigeonMap = <dynamic, dynamic>{};
final pigeonMap = <dynamic, dynamic>{};
pigeonMap['enabled'] = enabled;
return pigeonMap;
}
// ignore: unused_element
static IsEnabledMessage _fromMap(Map<dynamic, dynamic> pigeonMap) {
final IsEnabledMessage result = IsEnabledMessage();
final result = IsEnabledMessage();
result.enabled = pigeonMap['enabled'];
return result;
}
... ... @@ -42,18 +44,18 @@ class IsEnabledMessage {
class WakelockApi {
Future<void> toggle(ToggleMessage arg) async {
final Map<dynamic, dynamic> requestMap = arg._toMap();
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
final requestMap = arg._toMap();
const channel = BasicMessageChannel<dynamic>(
'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec());
final Map<dynamic, dynamic> replyMap = await channel.send(requestMap);
final replyMap = await channel.send(requestMap);
if (replyMap == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
details: null);
} else if (replyMap['error'] != null) {
final Map<dynamic, dynamic> error = replyMap['error'];
final error = replyMap['error'];
throw PlatformException(
code: error['code'],
message: error['message'],
... ... @@ -64,17 +66,17 @@ class WakelockApi {
}
Future<IsEnabledMessage> isEnabled() async {
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
const channel = BasicMessageChannel<dynamic>(
'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec());
final Map<dynamic, dynamic> replyMap = await channel.send(null);
final replyMap = await channel.send(null);
if (replyMap == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
details: null);
} else if (replyMap['error'] != null) {
final Map<dynamic, dynamic> error = replyMap['error'];
final error = replyMap['error'];
throw PlatformException(
code: error['code'],
message: error['message'],
... ... @@ -87,31 +89,32 @@ class WakelockApi {
abstract class TestWakelockApi {
void toggle(ToggleMessage arg);
IsEnabledMessage isEnabled();
static void setup(TestWakelockApi api) {
static void setup(TestWakelockApi? api) {
{
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
const channel = BasicMessageChannel<dynamic>(
'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec());
if (api == null) {
channel.setMockMessageHandler(null);
} else {
channel.setMockMessageHandler((dynamic message) async {
final Map<dynamic, dynamic> mapMessage =
message as Map<dynamic, dynamic>;
final ToggleMessage input = ToggleMessage._fromMap(mapMessage);
final mapMessage = message as Map<dynamic, dynamic>;
final input = ToggleMessage._fromMap(mapMessage);
api.toggle(input);
return <dynamic, dynamic>{};
});
}
}
{
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
const channel = BasicMessageChannel<dynamic>(
'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec());
if (api == null) {
channel.setMockMessageHandler(null);
} else {
channel.setMockMessageHandler((dynamic message) async {
final IsEnabledMessage output = api.isEnabled();
final output = api.isEnabled();
return <dynamic, dynamic>{'result': output._toMap()};
});
}
... ...
// Ignoring until pigeon is migrated to null safety.
// See https://github.com/flutter/flutter/issues/71360.
// ignore: import_of_legacy_library_into_null_safe
import 'package:wakelock_platform_interface/messages.dart';
import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';
... ...
... ... @@ -2,7 +2,7 @@ name: wakelock_platform_interface
description: >-2
A common platform interface for the wakelock plugin used by the different platform
implementations.
version: 0.1.0+1
version: 0.2.0-nullsafety.1
homepage: >-2
https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface
... ... @@ -14,7 +14,7 @@ dependencies:
flutter:
sdk: flutter
meta: 1.3.0-nullsafety.6
meta: ^1.3.0-nullsafety.0
dev_dependencies:
flutter_test:
... ...
import 'package:flutter_test/flutter_test.dart';
// Ignoring until pigeon is migrated to null safety.
// See https://github.com/flutter/flutter/issues/71360.
// ignore: import_of_legacy_library_into_null_safe
import 'package:wakelock_platform_interface/messages.dart';
import 'package:wakelock_platform_interface/method_channel_wakelock.dart';
import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';
... ...