Logging Lifecycle eingebaut

This commit is contained in:
Sven committed 2024-04-11 13:02:46 +02:00
1 parent cfbc0cf765
commit 32ec25af14
3 files changed
+40 -6

No files matched your search

+31 -6
View File
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:is_lock_screen/is_lock_screen.dart';
import 'package:isar/isar.dart';
import 'package:path_provider/path_provider.dart';
import 'package:stadtbote/messages/pop_content_view_message.dart';
@@ -54,12 +55,8 @@ void _traceUncaughtExceptions(Object error, StackTrace stackTrace) {
Util.logException('Stack-Trace: $stackTrace');
}
class MyApp extends StatelessWidget {
MyApp({super.key}) {
MqttCore.setup();
_startLocationService();
}
class MyApp extends StatefulWidget {
MyApp({super.key});
static late Isar isarInstance;
@@ -67,6 +64,34 @@ class MyApp extends StatelessWidget {
static bool suppressAcceptDialog = false;
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
@override
void initState() {
WidgetsBinding.instance.addObserver(this);
MqttCore.setup();
_startLocationService();
super.initState();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
super.didChangeAppLifecycleState(state);
Util.logInfo('Lifecylcle changes: $state');
}
@override
Widget build(BuildContext context) {
return MaterialApp(