app_lifecycle_state.dart 367 B

1234567891011121314151617
  1. import 'package:flutter/material.dart';
  2. abstract class LifecycleState<T extends StatefulWidget> extends State<T>
  3. with WidgetsBindingObserver {
  4. @override
  5. void initState() {
  6. super.initState();
  7. WidgetsBinding.instance?.addObserver(this);
  8. }
  9. @override
  10. void dispose() {
  11. WidgetsBinding.instance?.removeObserver(this);
  12. super.dispose();
  13. }
  14. }