From 27284531a49e5b60452e726dd2dc8ce72d156278 Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Sat, 13 Jul 2024 00:27:38 +0200 Subject: [PATCH] Test for Flutter 3.22 without try catch (#354) --- lib/src/core/lifecycle/lifecycle_notifier.dart | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/src/core/lifecycle/lifecycle_notifier.dart b/lib/src/core/lifecycle/lifecycle_notifier.dart index cacb0e08..384a9dac 100644 --- a/lib/src/core/lifecycle/lifecycle_notifier.dart +++ b/lib/src/core/lifecycle/lifecycle_notifier.dart @@ -41,15 +41,13 @@ class FlutterAppLifecycleNotifier extends ValueNotifier { /// Returns true if the current Flutter version is 3.22 or later bool _isBeforeFlutter3_22() { - final dynamic node = SemanticsNode(); - try { - // this property was added in https://github.com/flutter/flutter/pull/142826 - // ignore: unnecessary_statements, avoid_dynamic_calls - node.indexInParent; + final dynamic node = SemanticsNode()..indexInParent = 10; + final text = node.toString(); + // this property was added in https://github.com/flutter/flutter/pull/142826 + if (text.contains('indexInParent: 10')) { return false; - } catch (e) { - return true; } + return true; } /// A backwards compatible version of AppLifecycleState.hidden,