@@ -31,7 +31,7 @@ void _alarmManagerCallbackDispatcher() {
31
31
32
32
// PluginUtilities.getCallbackFromHandle performs a lookup based on the
33
33
// callback handle and returns a tear-off of the original callback.
34
- final Function closure = PluginUtilities .getCallbackFromHandle (handle);
34
+ final Function ? closure = PluginUtilities .getCallbackFromHandle (handle);
35
35
36
36
if (closure == null ) {
37
37
print ('Fatal: could not find callback' );
@@ -56,7 +56,7 @@ void _alarmManagerCallbackDispatcher() {
56
56
// A lambda that returns the current instant in the form of a [DateTime].
57
57
typedef DateTime _Now ();
58
58
// A lambda that gets the handle for the given [callback].
59
- typedef CallbackHandle _GetCallbackHandle (Function callback);
59
+ typedef CallbackHandle ? _GetCallbackHandle (Function callback);
60
60
61
61
/// A Flutter plugin for registering Dart callbacks with the Android
62
62
/// AlarmManager service.
@@ -77,7 +77,7 @@ class AndroidAlarmManager {
77
77
/// the plugin.
78
78
@visibleForTesting
79
79
static void setTestOverides (
80
- {_Now now, _GetCallbackHandle getCallbackHandle}) {
80
+ {_Now ? now, _GetCallbackHandle ? getCallbackHandle}) {
81
81
_now = (now ?? _now);
82
82
_getCallbackHandle = (getCallbackHandle ?? _getCallbackHandle);
83
83
}
@@ -88,12 +88,12 @@ class AndroidAlarmManager {
88
88
/// Returns a [Future] that resolves to `true` on success and `false` on
89
89
/// failure.
90
90
static Future <bool > initialize () async {
91
- final CallbackHandle handle =
91
+ final CallbackHandle ? handle =
92
92
_getCallbackHandle (_alarmManagerCallbackDispatcher);
93
93
if (handle == null ) {
94
94
return false ;
95
95
}
96
- final bool r = await _channel.invokeMethod <bool >(
96
+ final bool ? r = await _channel.invokeMethod <bool >(
97
97
'AlarmService.start' , < dynamic > [handle.toRawHandle ()]);
98
98
return r ?? false ;
99
99
}
@@ -207,11 +207,11 @@ class AndroidAlarmManager {
207
207
assert (callback is Function () || callback is Function (int ));
208
208
assert (id.bitLength < 32 );
209
209
final int startMillis = time.millisecondsSinceEpoch;
210
- final CallbackHandle handle = _getCallbackHandle (callback);
210
+ final CallbackHandle ? handle = _getCallbackHandle (callback);
211
211
if (handle == null ) {
212
212
return false ;
213
213
}
214
- final bool r =
214
+ final bool ? r =
215
215
await _channel.invokeMethod <bool >('Alarm.oneShotAt' , < dynamic > [
216
216
id,
217
217
alarmClock,
@@ -222,7 +222,7 @@ class AndroidAlarmManager {
222
222
rescheduleOnReboot,
223
223
handle.toRawHandle (),
224
224
]);
225
- return (r == null ) ? false : r ;
225
+ return r ?? false ;
226
226
}
227
227
228
228
/// Schedules a repeating timer to run `callback` with period `duration` .
@@ -262,7 +262,7 @@ class AndroidAlarmManager {
262
262
Duration duration,
263
263
int id,
264
264
Function callback, {
265
- DateTime startAt,
265
+ DateTime ? startAt,
266
266
bool exact = false ,
267
267
bool wakeup = false ,
268
268
bool rescheduleOnReboot = false ,
@@ -274,11 +274,11 @@ class AndroidAlarmManager {
274
274
final int period = duration.inMilliseconds;
275
275
final int first =
276
276
startAt != null ? startAt.millisecondsSinceEpoch : now + period;
277
- final CallbackHandle handle = _getCallbackHandle (callback);
277
+ final CallbackHandle ? handle = _getCallbackHandle (callback);
278
278
if (handle == null ) {
279
279
return false ;
280
280
}
281
- final bool r = await _channel.invokeMethod <bool >(
281
+ final bool ? r = await _channel.invokeMethod <bool >(
282
282
'Alarm.periodic' , < dynamic > [
283
283
id,
284
284
exact,
@@ -288,7 +288,7 @@ class AndroidAlarmManager {
288
288
rescheduleOnReboot,
289
289
handle.toRawHandle ()
290
290
]);
291
- return (r == null ) ? false : r ;
291
+ return r ?? false ;
292
292
}
293
293
294
294
/// Cancels a timer.
@@ -299,8 +299,8 @@ class AndroidAlarmManager {
299
299
/// Returns a [Future] that resolves to `true` on success and `false` on
300
300
/// failure.
301
301
static Future <bool > cancel (int id) async {
302
- final bool r =
302
+ final bool ? r =
303
303
await _channel.invokeMethod <bool >('Alarm.cancel' , < dynamic > [id]);
304
- return (r == null ) ? false : r ;
304
+ return r ?? false ;
305
305
}
306
306
}
0 commit comments