app_lifecycle_state.dart 360 B

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