Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Take the following code:
When running it on the web, it prints something like the following:
https://dartpad.dev?id=00c4616e433c9e1d06910c01d450d10e&run=true
The
hexStrings are equal, but thebytesdiffer. This caused quite some confusion in a Flutter web app we developed. The cause for this is how numbers work in Dart on the web:Specifically,
ObjectId.fromHexString(…)parses the five byte long process-unique part of the ObjectId into a number, and then extracts the individual bytes using shift operations – which works for the four lower bytes, but not the fifth one. (ThehexStringwas still equal because it was cached from the input argument.)To fix this, I split parsing the process unique part into two
int.parse(…)calls.