AOSSIE-Org / Resonate

Clubhouse, but Open Source. A social voice platform.
GNU General Public License v3.0
171 stars 123 forks source link

[BugFix] Fix for Null Check Operator Used on a Null Value Exception in UiSizes Class #291

Closed AyaNady17 closed 3 months ago

AyaNady17 commented 4 months ago

Description

This PR addresses the issue where a Null check operator used on a null value exception is thrown when trying to access Get.width and Get.height in the UiSizes class before the BuildContext is available.

The solution involves refactoring the UiSizes class to use late keyword for the size variables and initializing them in a new init method which is called after the BuildContext is available. 'MediaQuery' is used to get the screen sizes. Fixes #288

Changes:

  1. Refactored the UiSizes class to use late keyword for the size variables.
  2. Added an init method in UiSizes class to initialize the size variables using MediaQuery.
  3. Called UiSizes.init() in the build method of the main widget.

How Has This Been Tested?

  1. Run the app to ensure it loads without throwing the Null check operator used on a null value exception.
  2. Check various parts of the app to ensure that the sizes are being applied correctly.

https://github.com/AOSSIE-Org/Resonate/assets/144162711/57346fcb-7e5e-4e6b-9fd5-ed527b031c0a Screenshot (182)

Checklist:

Maintainer Checklist

AyaNady17 commented 4 months ago

please let me know your feedback. @chandansgowda

chandansgowda commented 4 months ago

Great job @AyaNady17 Please add a screen recording showing that the app works.

chandansgowda commented 4 months ago

Also, have you upgraded flutter to latest version ?

AyaNady17 commented 4 months ago

Great job @AyaNady17 Please add a screen recording showing that the app works.

done @chandansgowda

AyaNady17 commented 4 months ago

Also, have you upgraded flutter to latest version ?

until now I'm working on the Flutter 3.16.5 version. should i upgrade to the latest version before merging the changes? @chandansgowda

bhawesh2002 commented 4 months ago

Question: Instead of using late keyword can we directly use MediaQuery to get the screen size? I did the same thing in other one of my flutter app and it still worked fine. If this is possible we can avoid use of late keyword.

AyaNady17 commented 3 months ago

Question: Instead of using late keyword can we directly use MediaQuery to get the screen size? I did the same thing in other one of my flutter app and it still worked fine. If this is possible we can avoid use of late keyword.

if we declared sizes without using the late keyword, we must initialize it with a specific value. Otherwise, we’ll encounter an error. So, I think late keyword is essential for safely accessing context-related properties once they are fully available. if I get it wrong or you have another opinion to enhance it, please let's discuss it more. @bhawesh2002

chandansgowda commented 3 months ago

Great Job @AyaNady17

Also, have you upgraded flutter to latest version ?

until now I'm working on the Flutter 3.16.5 version. should i upgrade to the latest version before merging the changes? @chandansgowda

Let's upgrade before merging this PR.

AyaNady17 commented 3 months ago

Great Job @AyaNady17

Also, have you upgraded flutter to latest version ?

until now I'm working on the Flutter 3.16.5 version. should i upgrade to the latest version before merging the changes? @chandansgowda

Let's upgrade before merging this PR.

done, upgraded to the latest stable version with no errors. @chandansgowda

AyaNady17 commented 3 months ago

Due to the upgrade one of the packages (text field tags) updated to latest version where one of its attributes have changed and I refactored it to fit with the update so there's some changes in Ui file and pubspec.Yaml but now everything works well with the latest versions.

chandansgowda commented 3 months ago

Thanks for contributing @AyaNady17