monorepo/dialer/packages/mobile_number/lib/widget_lifecycle.dart
Bartosz 13376118c3
All checks were successful
/ mirror (push) Successful in 4s
add of sim changes
2024-11-28 20:57:58 +00:00

31 lines
778 B
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
class WidgetLifecycle extends WidgetsBindingObserver {
final AsyncCallback? resumeCallBack;
final AsyncCallback? suspendingCallBack;
WidgetLifecycle({
this.resumeCallBack,
this.suspendingCallBack,
});
@override
Future<Null> 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;
}
}
}