-
Notifications
You must be signed in to change notification settings - Fork 358
fix: [Flutter Web] TypeError JSArray #2224
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
base: master
Are you sure you want to change the base?
fix: [Flutter Web] TypeError JSArray #2224
Conversation
e84160d
to
9391452
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request addresses a Flutter Web TypeError related to JSArray by refining error handling and ensuring proper typed list initializations.
- Added a try-catch block with debug logging in channel_api.dart for queryChannels response processing
- Updated several list spread operations to use explicit generic list declarations in channel.dart
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
packages/stream_chat/lib/src/core/api/channel_api.dart | Added error handling for queryChannels response, returning an empty QueryChannelsResponse on error |
packages/stream_chat/lib/src/client/channel.dart | Updated list initializations with explicit generic types to resolve potential JSArray issues |
} catch (e) { | ||
debugPrint('queryChannels error: $e'); | ||
return QueryChannelsResponse.fromJson({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning an empty QueryChannelsResponse in the catch block may mask issues during JSON parsing. Consider handling the error more explicitly, such as propagating the error or providing a detailed error message.
} catch (e) { | |
debugPrint('queryChannels error: $e'); | |
return QueryChannelsResponse.fromJson({}); | |
} catch (e, stackTrace) { | |
debugPrint('queryChannels error: $e'); | |
throw QueryChannelsException( | |
'Failed to parse QueryChannelsResponse: $e', | |
stackTrace, | |
); |
Copilot uses AI. Check for mistakes.
|
||
// Remove quoted message reference from every message if available. | ||
updatedMessages = [...updatedMessages].map((it) { | ||
updatedMessages = <Message>[...updatedMessages].map((it) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mapping over the list returns an Iterable rather than a List. To ensure type consistency, consider appending .toList() after the map operation.
Copilot uses AI. Check for mistakes.
Submit a pull request
FYI, someone can forward this without me signing CLA
CLA
Description of the pull request