Skip to content

Conversation

@AyaNady17
Copy link
Member

@AyaNady17 AyaNady17 commented Mar 6, 2024

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:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tag the PR with the appropriate labels

@AyaNady17
Copy link
Member Author

please let me know your feedback. @chandansgowda

@chandansgowda
Copy link
Member

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

@chandansgowda
Copy link
Member

Also, have you upgraded flutter to latest version ?

@AyaNady17
Copy link
Member Author

AyaNady17 commented Mar 6, 2024

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

done @chandansgowda

@AyaNady17
Copy link
Member Author

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
Copy link
Contributor

bhawesh2002 commented Mar 7, 2024

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
Copy link
Member Author

AyaNady17 commented Mar 7, 2024

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
Copy link
Member

chandansgowda commented Mar 7, 2024

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.

…Tags widget due to the latest updates on the package
@AyaNady17
Copy link
Member Author

AyaNady17 commented Mar 7, 2024

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
Copy link
Member Author

AyaNady17 commented Mar 7, 2024

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
Copy link
Member

Thanks for contributing @AyaNady17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: _TypeError (Null check operator used on a null value)

3 participants