creativecreatorormaybenot
Committed by GitHub

Fix null safety issues (#60)

* Fix null safety issues

* Adjust README
1 -# 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) 1 +# 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)
2 2
3 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. 3 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.
4 4
  1 +## 0.2.0-nullsafety.1
  2 +
  3 +* Fix null safety issues.
  4 +
  5 +## 0.2.0-nullsafety.0
  6 +
  7 +* Migrated to null safety.
  8 +
1 ## 0.1.0+1 9 ## 0.1.0+1
2 10
3 * Updated messages with upgraded version of pigeon. 11 * Updated messages with upgraded version of pigeon.
1 -include: ../analysis_options.yaml  
2 -  
3 -analyzer:  
4 - exclude:  
5 - - 'lib/messages.dart'  
1 // Autogenerated from Pigeon (v0.1.14), do not edit directly. 1 // Autogenerated from Pigeon (v0.1.14), do not edit directly.
2 // See also: https://pub.dev/packages/pigeon 2 // See also: https://pub.dev/packages/pigeon
3 // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import 3 // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import
4 -// @dart = 2.8  
5 import 'dart:async'; 4 import 'dart:async';
6 -import 'package:flutter/services.dart';  
7 import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; 5 import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
8 6
  7 +import 'package:flutter/services.dart';
  8 +
9 class ToggleMessage { 9 class ToggleMessage {
10 - bool enable; 10 + late bool enable;
  11 +
11 // ignore: unused_element 12 // ignore: unused_element
12 Map<dynamic, dynamic> _toMap() { 13 Map<dynamic, dynamic> _toMap() {
13 - final Map<dynamic, dynamic> pigeonMap = <dynamic, dynamic>{}; 14 + final pigeonMap = <dynamic, dynamic>{};
14 pigeonMap['enable'] = enable; 15 pigeonMap['enable'] = enable;
15 return pigeonMap; 16 return pigeonMap;
16 } 17 }
17 18
18 // ignore: unused_element 19 // ignore: unused_element
19 static ToggleMessage _fromMap(Map<dynamic, dynamic> pigeonMap) { 20 static ToggleMessage _fromMap(Map<dynamic, dynamic> pigeonMap) {
20 - final ToggleMessage result = ToggleMessage(); 21 + final result = ToggleMessage();
21 result.enable = pigeonMap['enable']; 22 result.enable = pigeonMap['enable'];
22 return result; 23 return result;
23 } 24 }
24 } 25 }
25 26
26 class IsEnabledMessage { 27 class IsEnabledMessage {
27 - bool enabled; 28 + late bool enabled;
  29 +
28 // ignore: unused_element 30 // ignore: unused_element
29 Map<dynamic, dynamic> _toMap() { 31 Map<dynamic, dynamic> _toMap() {
30 - final Map<dynamic, dynamic> pigeonMap = <dynamic, dynamic>{}; 32 + final pigeonMap = <dynamic, dynamic>{};
31 pigeonMap['enabled'] = enabled; 33 pigeonMap['enabled'] = enabled;
32 return pigeonMap; 34 return pigeonMap;
33 } 35 }
34 36
35 // ignore: unused_element 37 // ignore: unused_element
36 static IsEnabledMessage _fromMap(Map<dynamic, dynamic> pigeonMap) { 38 static IsEnabledMessage _fromMap(Map<dynamic, dynamic> pigeonMap) {
37 - final IsEnabledMessage result = IsEnabledMessage(); 39 + final result = IsEnabledMessage();
38 result.enabled = pigeonMap['enabled']; 40 result.enabled = pigeonMap['enabled'];
39 return result; 41 return result;
40 } 42 }
@@ -42,18 +44,18 @@ class IsEnabledMessage { @@ -42,18 +44,18 @@ class IsEnabledMessage {
42 44
43 class WakelockApi { 45 class WakelockApi {
44 Future<void> toggle(ToggleMessage arg) async { 46 Future<void> toggle(ToggleMessage arg) async {
45 - final Map<dynamic, dynamic> requestMap = arg._toMap();  
46 - const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>( 47 + final requestMap = arg._toMap();
  48 + const channel = BasicMessageChannel<dynamic>(
47 'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); 49 'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec());
48 50
49 - final Map<dynamic, dynamic> replyMap = await channel.send(requestMap); 51 + final replyMap = await channel.send(requestMap);
50 if (replyMap == null) { 52 if (replyMap == null) {
51 throw PlatformException( 53 throw PlatformException(
52 code: 'channel-error', 54 code: 'channel-error',
53 message: 'Unable to establish connection on channel.', 55 message: 'Unable to establish connection on channel.',
54 details: null); 56 details: null);
55 } else if (replyMap['error'] != null) { 57 } else if (replyMap['error'] != null) {
56 - final Map<dynamic, dynamic> error = replyMap['error']; 58 + final error = replyMap['error'];
57 throw PlatformException( 59 throw PlatformException(
58 code: error['code'], 60 code: error['code'],
59 message: error['message'], 61 message: error['message'],
@@ -64,17 +66,17 @@ class WakelockApi { @@ -64,17 +66,17 @@ class WakelockApi {
64 } 66 }
65 67
66 Future<IsEnabledMessage> isEnabled() async { 68 Future<IsEnabledMessage> isEnabled() async {
67 - const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>( 69 + const channel = BasicMessageChannel<dynamic>(
68 'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); 70 'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec());
69 71
70 - final Map<dynamic, dynamic> replyMap = await channel.send(null); 72 + final replyMap = await channel.send(null);
71 if (replyMap == null) { 73 if (replyMap == null) {
72 throw PlatformException( 74 throw PlatformException(
73 code: 'channel-error', 75 code: 'channel-error',
74 message: 'Unable to establish connection on channel.', 76 message: 'Unable to establish connection on channel.',
75 details: null); 77 details: null);
76 } else if (replyMap['error'] != null) { 78 } else if (replyMap['error'] != null) {
77 - final Map<dynamic, dynamic> error = replyMap['error']; 79 + final error = replyMap['error'];
78 throw PlatformException( 80 throw PlatformException(
79 code: error['code'], 81 code: error['code'],
80 message: error['message'], 82 message: error['message'],
@@ -87,31 +89,32 @@ class WakelockApi { @@ -87,31 +89,32 @@ class WakelockApi {
87 89
88 abstract class TestWakelockApi { 90 abstract class TestWakelockApi {
89 void toggle(ToggleMessage arg); 91 void toggle(ToggleMessage arg);
  92 +
90 IsEnabledMessage isEnabled(); 93 IsEnabledMessage isEnabled();
91 - static void setup(TestWakelockApi api) { 94 +
  95 + static void setup(TestWakelockApi? api) {
92 { 96 {
93 - const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>( 97 + const channel = BasicMessageChannel<dynamic>(
94 'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); 98 'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec());
95 if (api == null) { 99 if (api == null) {
96 channel.setMockMessageHandler(null); 100 channel.setMockMessageHandler(null);
97 } else { 101 } else {
98 channel.setMockMessageHandler((dynamic message) async { 102 channel.setMockMessageHandler((dynamic message) async {
99 - final Map<dynamic, dynamic> mapMessage =  
100 - message as Map<dynamic, dynamic>;  
101 - final ToggleMessage input = ToggleMessage._fromMap(mapMessage); 103 + final mapMessage = message as Map<dynamic, dynamic>;
  104 + final input = ToggleMessage._fromMap(mapMessage);
102 api.toggle(input); 105 api.toggle(input);
103 return <dynamic, dynamic>{}; 106 return <dynamic, dynamic>{};
104 }); 107 });
105 } 108 }
106 } 109 }
107 { 110 {
108 - const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>( 111 + const channel = BasicMessageChannel<dynamic>(
109 'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); 112 'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec());
110 if (api == null) { 113 if (api == null) {
111 channel.setMockMessageHandler(null); 114 channel.setMockMessageHandler(null);
112 } else { 115 } else {
113 channel.setMockMessageHandler((dynamic message) async { 116 channel.setMockMessageHandler((dynamic message) async {
114 - final IsEnabledMessage output = api.isEnabled(); 117 + final output = api.isEnabled();
115 return <dynamic, dynamic>{'result': output._toMap()}; 118 return <dynamic, dynamic>{'result': output._toMap()};
116 }); 119 });
117 } 120 }
1 -// Ignoring until pigeon is migrated to null safety.  
2 -// See https://github.com/flutter/flutter/issues/71360.  
3 -// ignore: import_of_legacy_library_into_null_safe  
4 import 'package:wakelock_platform_interface/messages.dart'; 1 import 'package:wakelock_platform_interface/messages.dart';
5 import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; 2 import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';
6 3
@@ -2,7 +2,7 @@ name: wakelock_platform_interface @@ -2,7 +2,7 @@ name: wakelock_platform_interface
2 description: >-2 2 description: >-2
3 A common platform interface for the wakelock plugin used by the different platform 3 A common platform interface for the wakelock plugin used by the different platform
4 implementations. 4 implementations.
5 -version: 0.1.0+1 5 +version: 0.2.0-nullsafety.1
6 homepage: >-2 6 homepage: >-2
7 https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface 7 https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface
8 8
@@ -14,7 +14,7 @@ dependencies: @@ -14,7 +14,7 @@ dependencies:
14 flutter: 14 flutter:
15 sdk: flutter 15 sdk: flutter
16 16
17 - meta: 1.3.0-nullsafety.6 17 + meta: ^1.3.0-nullsafety.0
18 18
19 dev_dependencies: 19 dev_dependencies:
20 flutter_test: 20 flutter_test:
1 import 'package:flutter_test/flutter_test.dart'; 1 import 'package:flutter_test/flutter_test.dart';
2 -// Ignoring until pigeon is migrated to null safety.  
3 -// See https://github.com/flutter/flutter/issues/71360.  
4 -// ignore: import_of_legacy_library_into_null_safe  
5 import 'package:wakelock_platform_interface/messages.dart'; 2 import 'package:wakelock_platform_interface/messages.dart';
6 import 'package:wakelock_platform_interface/method_channel_wakelock.dart'; 3 import 'package:wakelock_platform_interface/method_channel_wakelock.dart';
7 import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; 4 import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';