summaryrefslogtreecommitdiff
path: root/lib/widgets/device_details.dart
diff options
context:
space:
mode:
authoruvok2025-07-31 15:55:08 +0200
committeruvok2025-07-31 15:55:08 +0200
commit9143f2f16b5511b016a107adb5a38d34d1bc9677 (patch)
treeee3a4a023c34e1d937cc164ca043fcd71b5c8fd9 /lib/widgets/device_details.dart
parent7cd3cb2d284c4c7b2e3831ec23a44b2d62d6d550 (diff)
Close connection on app exit
Diffstat (limited to 'lib/widgets/device_details.dart')
-rw-r--r--lib/widgets/device_details.dart23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/widgets/device_details.dart b/lib/widgets/device_details.dart
index 79f76cf..e481303 100644
--- a/lib/widgets/device_details.dart
+++ b/lib/widgets/device_details.dart
@@ -13,6 +13,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
+import 'dart:ui';
+
import 'package:uvok_epaper_badge/model/device/device.dart';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
@@ -38,10 +40,21 @@ class DeviceDetailsScreen extends StatefulWidget {
class DeviceDetailsState extends State<DeviceDetailsScreen> {
String connectStatus = "<Status>";
+ late final AppLifecycleListener appLL;
/// Whether the back button should be active.
bool backActive = false;
+ DeviceDetailsState() {
+ appLL = AppLifecycleListener(
+ onExitRequested: () async {
+ logger.i("Exit requested");
+ dispose();
+ return AppExitResponse.exit;
+ },
+ );
+ }
+
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -76,12 +89,18 @@ class DeviceDetailsState extends State<DeviceDetailsScreen> {
@override
void deactivate() {
- widget.deviceConnection.disconnect().ignore();
- logger.i("Closing state");
+ logger.i("(widget deactivate)");
// widget.device.disconnect().ignore();
super.deactivate();
}
+ @override
+ void dispose() {
+ logger.i("(widget dispose)");
+ widget.deviceConnection.disconnect().ignore();
+ super.dispose();
+ }
+
void _doConnect() async {
final dev = widget.device;