Skip to content

Commit

Permalink
Test for Flutter 3.22 without try catch (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy authored Jul 12, 2024
1 parent 636c558 commit 2728453
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/src/core/lifecycle/lifecycle_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ class FlutterAppLifecycleNotifier extends ValueNotifier<AppLifecycleState> {

/// 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,
Expand Down

0 comments on commit 2728453

Please sign in to comment.