wake lock implemented

This commit is contained in:
Constantin Leue
2026-08-03 21:26:36 +02:00
parent 5dfd28c56b
commit 7b198e1755
5 changed files with 55 additions and 6 deletions
+21 -6
View File
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:wakelock_plus/wakelock_plus.dart';
import '../app_mode/app_mode_cubit.dart';
import 'screens/fly/fly_screen.dart';
@@ -18,12 +19,26 @@ class AppShell extends StatelessWidget {
final mode = context.select((AppModeCubit c) => c.state.mode);
final screen = mode == AppMode.fly ? const FlyScreen() : const PlanScreen();
return Scaffold(
body: Stack(
children: [
Positioned.fill(child: screen),
const Align(alignment: Alignment.topCenter, child: TopModeBar()),
],
return BlocListener<AppModeCubit, AppModeState>(
listenWhen: (previous, current) => previous.mode != current.mode,
listener: (context, state) {
// Nur FLAG_KEEP_SCREEN_ON, kein PowerManager.WakeLock (Doku 4.20
// deckt den Foreground-Service fuer Hintergrund-Telemetrie separat
// ab). Android-Empfehlung: an die Activity-Sichtbarkeit gebunden,
// keine Permission, kein manuelles Leak-Risiko.
if (state.mode == AppMode.fly) {
WakelockPlus.enable();
} else {
WakelockPlus.disable();
}
},
child: Scaffold(
body: Stack(
children: [
Positioned.fill(child: screen),
const Align(alignment: Alignment.topCenter, child: TopModeBar()),
],
),
),
);
}