// Label StoreMAX // // Created by Anthony Gordon. // Copyright © 2020 WooSignal. All rights reserved. // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; class LifecycleEventHandler extends WidgetsBindingObserver { final AsyncCallback resumeCallBack; final AsyncCallback suspendingCallBack; LifecycleEventHandler({ this.resumeCallBack, this.suspendingCallBack, }); @override Future didChangeAppLifecycleState(AppLifecycleState state) async { switch (state) { case AppLifecycleState.resumed: if (resumeCallBack != null) { await resumeCallBack(); } break; case AppLifecycleState.inactive: case AppLifecycleState.paused: case AppLifecycleState.detached: if (suspendingCallBack != null) { await suspendingCallBack(); } break; } } }