We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
My code is implementing a fromJson method calling the deserializeWith method returning an optional.
Is it safe for me to return a Beacon and not a Beacon? ?
In which case a null will be returned from the deserializeWith method
Code would be simple to maintain if method is returning a non nullable value and throw exception when required
static Beacon? fromJson(String jsonString) { return serializers.deserializeWith( Beacon.serializer, json.decode(jsonString)); }
The text was updated successfully, but these errors were encountered:
That depends on the JSON.
Will it ever be the literal null? If so, deserialize can return null, and your method must return Beacon?.
null
Beacon?
If not, you should add a ! to the return statement and return Beacon. Then it will throw if the JSON says null.
!
Beacon
Sorry, something went wrong.
davidmorgan
No branches or pull requests
My code is implementing a fromJson method calling the deserializeWith method returning an optional.
Is it safe for me to return a Beacon and not a Beacon? ?
In which case a null will be returned from the deserializeWith method
Code would be simple to maintain if method is returning a non nullable value and throw exception when required
The text was updated successfully, but these errors were encountered: