- import 'package:flutter/material.dart';
- abstract class LifecycleState<T extends StatefulWidget> extends State<T> with WidgetsBindingObserver {
- @override
- void initState() {
- super.initState();
- WidgetsBinding.instance.addObserver(this);
- }
- @override
- void dispose() {
- super.dispose();
- WidgetsBinding.instance.removeObserver(this);
- }
- }
|