myAppController top-level constant
String
const myAppController
Implementation
const myAppController = """
// to control app is background or foreground
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class MyAppController extends GetxController with WidgetsBindingObserver {
@override
void onInit() {
super.onInit();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
case AppLifecycleState.resumed:
break;
case AppLifecycleState.inactive:
break;
case AppLifecycleState.paused:
break;
case AppLifecycleState.detached:
break;
}
}
}
""";