Skip to content

Commit

Permalink
fix: Ambiguation is not needed in render box anymore (#2711)
Browse files Browse the repository at this point in the history
Since we are requiring a SDK higher than when the instance could be null we don't need to do the ambiguate call anymore.
  • Loading branch information
spydon committed Sep 10, 2023
1 parent 93dcb3a commit b3d78f5
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions packages/flame/lib/src/game/game_render_box.dart
Expand Up @@ -131,25 +131,15 @@ class GameRenderBox extends RenderBox with WidgetsBindingObserver {
}

void _bindLifecycleListener() {
_ambiguate(WidgetsBinding.instance)!.addObserver(this);
WidgetsBinding.instance.addObserver(this);
}

void _unbindLifecycleListener() {
_ambiguate(WidgetsBinding.instance)!.removeObserver(this);
WidgetsBinding.instance.removeObserver(this);
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
game.lifecycleStateChange(state);
}
}

/// This allows a value of type T or T?
/// to be treated as a value of type T?.
///
/// We use this so that APIs that have become
/// non-nullable can still be used with `!` and `?`
/// to support older versions of the API as well.
///
/// See more: https://docs.flutter.dev/development/tools/sdk/release-notes/release-notes-3.0.0
T? _ambiguate<T>(T? value) => value;

0 comments on commit b3d78f5

Please sign in to comment.