@@ -31,7 +31,7 @@ void _alarmManagerCallbackDispatcher() {
3131
3232 // PluginUtilities.getCallbackFromHandle performs a lookup based on the
3333 // 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);
3535
3636 if (closure == null ) {
3737 print ('Fatal: could not find callback' );
@@ -56,7 +56,7 @@ void _alarmManagerCallbackDispatcher() {
5656// A lambda that returns the current instant in the form of a [DateTime].
5757typedef DateTime _Now ();
5858// A lambda that gets the handle for the given [callback].
59- typedef CallbackHandle _GetCallbackHandle (Function callback);
59+ typedef CallbackHandle ? _GetCallbackHandle (Function callback);
6060
6161/// A Flutter plugin for registering Dart callbacks with the Android
6262/// AlarmManager service.
@@ -77,7 +77,7 @@ class AndroidAlarmManager {
7777 /// the plugin.
7878 @visibleForTesting
7979 static void setTestOverides (
80- {_Now now, _GetCallbackHandle getCallbackHandle}) {
80+ {_Now ? now, _GetCallbackHandle ? getCallbackHandle}) {
8181 _now = (now ?? _now);
8282 _getCallbackHandle = (getCallbackHandle ?? _getCallbackHandle);
8383 }
@@ -88,12 +88,12 @@ class AndroidAlarmManager {
8888 /// Returns a [Future] that resolves to `true` on success and `false` on
8989 /// failure.
9090 static Future <bool > initialize () async {
91- final CallbackHandle handle =
91+ final CallbackHandle ? handle =
9292 _getCallbackHandle (_alarmManagerCallbackDispatcher);
9393 if (handle == null ) {
9494 return false ;
9595 }
96- final bool r = await _channel.invokeMethod <bool >(
96+ final bool ? r = await _channel.invokeMethod <bool >(
9797 'AlarmService.start' , < dynamic > [handle.toRawHandle ()]);
9898 return r ?? false ;
9999 }
@@ -207,11 +207,11 @@ class AndroidAlarmManager {
207207 assert (callback is Function () || callback is Function (int ));
208208 assert (id.bitLength < 32 );
209209 final int startMillis = time.millisecondsSinceEpoch;
210- final CallbackHandle handle = _getCallbackHandle (callback);
210+ final CallbackHandle ? handle = _getCallbackHandle (callback);
211211 if (handle == null ) {
212212 return false ;
213213 }
214- final bool r =
214+ final bool ? r =
215215 await _channel.invokeMethod <bool >('Alarm.oneShotAt' , < dynamic > [
216216 id,
217217 alarmClock,
@@ -222,7 +222,7 @@ class AndroidAlarmManager {
222222 rescheduleOnReboot,
223223 handle.toRawHandle (),
224224 ]);
225- return (r == null ) ? false : r ;
225+ return r ?? false ;
226226 }
227227
228228 /// Schedules a repeating timer to run `callback` with period `duration` .
@@ -262,7 +262,7 @@ class AndroidAlarmManager {
262262 Duration duration,
263263 int id,
264264 Function callback, {
265- DateTime startAt,
265+ DateTime ? startAt,
266266 bool exact = false ,
267267 bool wakeup = false ,
268268 bool rescheduleOnReboot = false ,
@@ -274,11 +274,11 @@ class AndroidAlarmManager {
274274 final int period = duration.inMilliseconds;
275275 final int first =
276276 startAt != null ? startAt.millisecondsSinceEpoch : now + period;
277- final CallbackHandle handle = _getCallbackHandle (callback);
277+ final CallbackHandle ? handle = _getCallbackHandle (callback);
278278 if (handle == null ) {
279279 return false ;
280280 }
281- final bool r = await _channel.invokeMethod <bool >(
281+ final bool ? r = await _channel.invokeMethod <bool >(
282282 'Alarm.periodic' , < dynamic > [
283283 id,
284284 exact,
@@ -288,7 +288,7 @@ class AndroidAlarmManager {
288288 rescheduleOnReboot,
289289 handle.toRawHandle ()
290290 ]);
291- return (r == null ) ? false : r ;
291+ return r ?? false ;
292292 }
293293
294294 /// Cancels a timer.
@@ -299,8 +299,8 @@ class AndroidAlarmManager {
299299 /// Returns a [Future] that resolves to `true` on success and `false` on
300300 /// failure.
301301 static Future <bool > cancel (int id) async {
302- final bool r =
302+ final bool ? r =
303303 await _channel.invokeMethod <bool >('Alarm.cancel' , < dynamic > [id]);
304- return (r == null ) ? false : r ;
304+ return r ?? false ;
305305 }
306306}
0 commit comments