appwrite / sdk-for-flutter

[READ-ONLY] Official Appwrite Flutter SDK 💙
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
364 stars 109 forks source link

fixing Unhandled Exception: type 'Null' is not a subtype of type 'Lis… #185

Closed iaggocapitanio1 closed 5 months ago

iaggocapitanio1 commented 9 months ago

What does this PR do?

This PR resolves Issue #173 by implementing a fix in the serialization process of the User class. The labels field, which previously could lead to a type cast error when null, has been adjusted to handle null values gracefully. This change ensures that when labels is null, it defaults to an empty list, thereby avoiding the "type 'Null' is not a subtype of type 'List'" error.

Test Plan

To verify these changes:

  1. Added unit tests to ensure that the User.fromMap method correctly handles cases where labels is null.
  2. Conducted manual testing to ensure that serialization and deserialization of User objects work as expected, even when labels is null.
  3. Reviewed all other usages of the User class to ensure compatibility with this change.

Related PRs and Issues

This PR directly resolves Issue #173. No other related PRs at this time.

Additional Information

This change is a crucial step towards robust and error-resistant handling of optional fields in data models, enhancing the stability of the Appwrite codebase.

Have you read the Contributing Guidelines on issues?

Yes, I have read the contributing guidelines and ensured that my PR aligns with them.


Schrolli91 commented 7 months ago

I think this can be closed because the Bug from #173 is fixed in the SDK generator now: https://github.com/appwrite/sdk-generator/pull/751

stnguyen90 commented 5 months ago

Unfortunately, this is a read-only repo as the code is generated by our SDK Generator, and changes made only here would be wiped in the next release.