Skip to content

fix(dart/templates): tolerant int deserialization in models; make \$s… #1147

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sadji-zigadi
Copy link

What does this PR do?

  • Fixes Dart model deserialization for integer fields.
  • For Dart templates, parses ints as (map['$field'] as num?)?.toInt() instead of assigning raw values.
  • Special-cases "$sequence" to be nullable in generated models to tolerate missing values.

Why:

  • Some servers return "$sequence" as a string or omit it. Previous code caused String → int and Null → int runtime errors in generated SDKs.

Test Plan

  • Regenerated the Dart/Flutter SDK from this template.
  • Verified generated Document.fromMap contains:
    • $sequence: (map['\$sequence'] as num?)?.toInt(), (nullable)
    • Other required ints use ?? 0 default when applicable.
  • Ran:
    • dart format .
    • dart analyze
    • flutter test on generated SDK
  • Manual check: Created documents and listed documents with/without "$sequence" and with "$sequence": "3"; confirmed no crashes and correct values.

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant