From c8ed07e9158a693548cfc9ed13601c38e504cadb Mon Sep 17 00:00:00 2001 From: Julian Steenbakker Date: Mon, 22 Mar 2021 10:36:02 +0100 Subject: [PATCH] refactor: changed lifecycle callback to late --- lib/src/lifecycle_event_handler.dart | 14 +++----------- lib/src/qr_code_scanner.dart | 5 ++--- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/src/lifecycle_event_handler.dart b/lib/src/lifecycle_event_handler.dart index f2bfe15..0580d17 100644 --- a/lib/src/lifecycle_event_handler.dart +++ b/lib/src/lifecycle_event_handler.dart @@ -3,28 +3,20 @@ import 'package:flutter/foundation.dart'; class LifecycleEventHandler extends WidgetsBindingObserver { LifecycleEventHandler({ - this.resumeCallBack, - this.suspendingCallBack, + required this.resumeCallBack, }); - final AsyncCallback? resumeCallBack; - final AsyncCallback? suspendingCallBack; + late final AsyncCallback resumeCallBack; @override Future didChangeAppLifecycleState(AppLifecycleState state) async { switch (state) { case AppLifecycleState.resumed: - if (resumeCallBack != null) { - await resumeCallBack!(); - } + await resumeCallBack(); break; case AppLifecycleState.inactive: case AppLifecycleState.paused: case AppLifecycleState.detached: - if (suspendingCallBack != null) { - await suspendingCallBack!(); - } - break; } } } diff --git a/lib/src/qr_code_scanner.dart b/lib/src/qr_code_scanner.dart index 23b7589..a3cefd8 100644 --- a/lib/src/qr_code_scanner.dart +++ b/lib/src/qr_code_scanner.dart @@ -98,7 +98,6 @@ class _QRViewState extends State { widget.key as GlobalKey>, _channel, overlay: widget.overlay) }); - return false; } @@ -139,7 +138,7 @@ class _QRViewState extends State { break; default: throw UnsupportedError( - "Trying to use the default webview implementation for $defaultTargetPlatform but there isn't a default one"); + "Trying to use the default qrview implementation for $defaultTargetPlatform but there isn't a default one"); } return _platformQrView; } @@ -199,7 +198,7 @@ class QRViewController { } break; case 'onPermissionSet': - await getSystemFeatures(); // if we have no permission all features will not be avaible + await getSystemFeatures(); // if we have no permission all features will not be available if (call.arguments != null) { if (call.arguments as bool) { _hasPermissions = true;