Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/all_plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
fetch-depth: 0
- name: 'Install Flutter'
run: ./.github/workflows/scripts/install-flutter.sh stable
run: ./.github/workflows/scripts/install-flutter.sh beta
- name: 'Install Tools'
run: |
./.github/workflows/scripts/install-tools.sh
Expand Down
4 changes: 4 additions & 0 deletions packages/android_alarm_manager_plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.0-nullsafety.0

- Migrated to null safety

## 0.5.0

- Transfer to plus-plugins monorepo
Expand Down
7 changes: 5 additions & 2 deletions packages/android_alarm_manager_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class AlarmManagerExampleApp extends StatelessWidget {
}

class _AlarmHomePage extends StatefulWidget {
_AlarmHomePage({Key key, this.title}) : super(key: key);
_AlarmHomePage({
Key key,
this.title,
}) : super(key: key);
final String title;

@override
Expand Down Expand Up @@ -140,7 +143,7 @@ class _AlarmHomePageState extends State<_AlarmHomePage> {
await AndroidAlarmManager.oneShot(
const Duration(seconds: 5),
// Ensure we have a unique alarm ID.
Random().nextInt(pow(2, 31)),
Random().nextInt(pow(2, 31).toInt()),
callback,
exact: true,
wakeup: true,
Expand Down
6 changes: 5 additions & 1 deletion packages/android_alarm_manager_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: android_alarm_manager_example
description: Demonstrates how to use the android_alarm_manager_plus plugin.

environment:
sdk: ">=2.10.0 <3.0.0"
flutter: ">=1.20.0 <2.0.0"

dependencies:
flutter:
sdk: flutter
android_alarm_manager_plus:
path: ../
shared_preferences: ^0.5.6
e2e: 0.3.0
integration_test: ^0.9.2
path_provider: ^1.3.1

dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:async';
import 'dart:io';
import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
import 'package:e2e/e2e.dart';
import 'package:integration_test/integration_test.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -55,7 +55,7 @@ Future<void> incrementCounter() async {
}

void main() {
E2EWidgetsFlutterBinding.ensureInitialized();
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

setUp(() async {
await AndroidAlarmManager.initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,19 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'dart:convert';
import 'dart:io';

// ignore: import_of_legacy_library_into_null_safe
import 'package:flutter_driver/flutter_driver.dart';
import 'package:vm_service_client/vm_service_client.dart';

Future<StreamSubscription<VMIsolateRef>> resumeIsolatesOnPause(
FlutterDriver driver) async {
final vm = await driver.serviceClient.getVM();
print('for isolates');
for (var isolateRef in vm.isolates) {
final isolate = await isolateRef.load();
if (isolate.isPaused) {
print('isolate.resume');
await isolate.resume();
}
}
return driver.serviceClient.onIsolateRunnable
.asBroadcastStream()
.listen((VMIsolateRef isolateRef) async {
print('onIsolateRunnable');
final isolate = await isolateRef.load();
if (isolate.isPaused) {
print('isolate.resume');
await isolate.resume();
}
});
}

Future<void> main() async {
final driver = await FlutterDriver.connect();
// flutter drive causes isolates to be paused on spawn. The background isolate
// for this plugin will need to be resumed for the test to pass.
final subscription = await resumeIsolatesOnPause(driver);
final result =
await driver.requestData(null, timeout: const Duration(minutes: 5));
final data = await driver.requestData(
null,
timeout: const Duration(minutes: 1),
);
await driver.close();
await subscription.cancel();
exit(result == 'pass' ? 0 : 1);
final Map<String, dynamic> result = jsonDecode(data);
exit(result['result'] == 'true' ? 0 : 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void _alarmManagerCallbackDispatcher() {
// A lambda that returns the current instant in the form of a [DateTime].
typedef _Now = DateTime Function();
// A lambda that gets the handle for the given [callback].
typedef _GetCallbackHandle = CallbackHandle Function(Function callback);
typedef _GetCallbackHandle = CallbackHandle? Function(Function callback);

/// A Flutter plugin for registering Dart callbacks with the Android
/// AlarmManager service.
Expand All @@ -77,8 +77,10 @@ class AndroidAlarmManager {
/// This is exposed for the unit tests. It should not be accessed by users of
/// the plugin.
@visibleForTesting
static void setTestOverides(
{_Now now, _GetCallbackHandle getCallbackHandle}) {
static void setTestOverides({
_Now? now,
_GetCallbackHandle? getCallbackHandle,
}) {
_now = (now ?? _now);
_getCallbackHandle = (getCallbackHandle ?? _getCallbackHandle);
}
Expand Down Expand Up @@ -261,7 +263,7 @@ class AndroidAlarmManager {
Duration duration,
int id,
Function callback, {
DateTime startAt,
DateTime? startAt,
bool exact = false,
bool wakeup = false,
bool rescheduleOnReboot = false,
Expand Down
8 changes: 4 additions & 4 deletions packages/android_alarm_manager_plus/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: android_alarm_manager_plus
description: Flutter plugin for accessing the Android AlarmManager service, and
running Dart code in the background when alarms fire.
version: 0.5.0
version: 0.6.0-nullsafety.0
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand All @@ -12,7 +12,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.9.0
pedantic: ^1.10.0-nullsafety.3

flutter:
plugin:
Expand All @@ -22,5 +22,5 @@ flutter:
pluginClass: AndroidAlarmManagerPlugin

environment:
sdk: ">=2.1.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
sdk: ">=2.12.0-29.10.beta <3.0.0"
flutter: ">=1.24.0-10.2.pre <2.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();

setUpAll(() {
testChannel.setMockMethodCallHandler((MethodCall call) => null);
testChannel
.setMockMethodCallHandler((MethodCall call) => Future.value(null));
});

test('${AndroidAlarmManager.initialize}', () async {
Expand Down