Skip to content
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

[bug] 'Null' is not a subtype of type 'String' in type cast #2

Closed
tiltmaster opened this issue Jan 31, 2024 · 3 comments
Closed

[bug] 'Null' is not a subtype of type 'String' in type cast #2

tiltmaster opened this issue Jan 31, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@tiltmaster
Copy link

Describe the bug
An error appears when trying to pass emoji set as below per example documentation:

'Null' is not a subtype of type 'String' in type cast

emojiSet: [
  CategoryEmoji(
  Category.ANIMALS,
    [Emoji.fromJson({})],
   )
 ],

Steps to Reproduce

  1. Open Camera
  2. Navigate to ProImageEditor

Expected Behavior
To work as expected and open up the emoji tab

@tiltmaster tiltmaster added the bug Something isn't working label Jan 31, 2024
@hm21
Copy link
Owner

hm21 commented Jan 31, 2024

Thanks for the bug report.

I've updated the example with the following code, which is more straightforward and easier to understand:

emojiSet: [
    CategoryEmoji(
      Category.ANIMALS,
      [
        Emoji(
          'emoji',
          'name',
          hasSkinTone: false,
        ),
      ],
    )
  ],

When using Emoji.fromJson, it's crucial to ensure that you provide values for all the required parameters. The method Emoji.fromJson works like this:

 static Emoji fromJson(Map<String, dynamic> json) {
    return Emoji(
      json['emoji'] as String,
      json['name'] as String,
      hasSkinTone:
          json['hasSkinTone'] != null ? json['hasSkinTone'] as bool : false,
    );
  }

@tiltmaster
Copy link
Author

Thanks for the bug report.

I've updated the example with the following code, which is more straightforward and easier to understand:

emojiSet: [
    CategoryEmoji(
      Category.ANIMALS,
      [
        Emoji(
          'emoji',
          'name',
          hasSkinTone: false,
        ),
      ],
    )
  ],

When using Emoji.fromJson, it's crucial to ensure that you provide values for all the required parameters. The method Emoji.fromJson works like this:

 static Emoji fromJson(Map<String, dynamic> json) {
    return Emoji(
      json['emoji'] as String,
      json['name'] as String,
      hasSkinTone:
          json['hasSkinTone'] != null ? json['hasSkinTone'] as bool : false,
    );
  }

Much Appreciated, using null also works by loading all emojis, but seeing a value of "null" makes it confusing as in to showing nothing. works like a charm

@tiltmaster
Copy link
Author

Much Appreciated, using null also works by loading all emojis, but seeing a value of "null" makes it confusing as in to showing nothing. works like a charm

hm21 added a commit that referenced this issue Jan 31, 2024
Addressed the example bug in `emojiSet`, providing a fix that aligns with the details discussed in GitHub issue #2 (#2 (comment)). This update ensures `emojiSet` functions as intended.
@Kora3 Kora3 mentioned this issue Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants