-
-
Notifications
You must be signed in to change notification settings - Fork 908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BoundedPositionBehavior fails with target == null #2655
Comments
This doesn't seem to be a problem in 1.8.2, could you try with that version? |
Actually I am working on 1.8.1, but have lowered the minimum working sample to 1.5.0, because I did not know how to make zapp.run working with 1.8.1. I tried it now also with 1.8.2, and the problem stays the same. |
Can you post the stack trace and assertions that you get in 1.8.2? The Zapp example is having some other problems too. |
Here is the stack trace for 1.8.2.
|
…is null (#2926) The `bounds` setter of `BoundedPositionBehavior` tries to update the target's position when bounds are updated. But it wasn't checking if the target is null. This was causing null exceptions while updating bounds of an unmounted `BoundedPositionBehavior` with null target (as seen in [this failing test case](https://github.com/flame-engine/flame/actions/runs/7231182930/job/19704091006#step:5:1291)). This PR fixes that by checking if the target is null before updating the position. Closes #2655
Current bug behavior
When I call CameraComponent.setBounds it fails, because BoundedPositionBehavior's _target is null. I traced it down to line 45 in packages/flame/lib/src/camera/behaviors/bounded_position_behavior.dart where _target! is used. In this case it is null, and the exception occurs.
Expected behavior
I would expect setBounds not to fail.
Steps to reproduce
Here is the example that causes a null exception https://zapp.run/edit/flame-zl3i06lvl3j0?entry=lib/main.dart&file=lib/main.dart
Flutter doctor output
I don't believe flutter doctor output is relevant here since there is an example from zapp.run attached.
More environment information
Log information
More information
The text was updated successfully, but these errors were encountered: