Bug Description
Flutter web release mode always errors out instead of returning an Algolia snapshot.
I have a fix at the bottom. It should at least help point in the right direction.
This is only in release mode and not debug mode. An error is printed to the browser console:
NoSuchMethodError: method not found: 'h' on null
(Note that flutter web will replace method names so 'h' doesn't really mean anything.)
Reproduction
Steps to reproduce the behavior:
Setup an Algolia index
Build any flutter project for web (in release mode).
Try to query any objects from Algolia.
Expected behavior
When query() is called, then an Algolia snapshot is returned with correct hits.
Desktop (please complete the following information):
Browser [chrome]
This bug only appears in release mode. It does not happen in debug mode.
Additional context / Fix
I was able to fix the issue by replacing
lib/src/algolia.dart: line 111
return response;
Right now it is:
return json.decode(response.body);
I'm pretty sure that the return type should be http.Response, however json.decode is returning dynamic. I'm not 100% sure why it works in debug mode and not release, or why this fixes it.
Please let me know if you need any more info.
Dart version: [ eg: 2.14.2 ] Flutter version: [ eg: 2.5.1 ]
Bug Description Flutter web release mode always errors out instead of returning an Algolia snapshot. I have a fix at the bottom. It should at least help point in the right direction.
This is only in release mode and not debug mode. An error is printed to the browser console:
NoSuchMethodError: method not found: 'h' on null
(Note that flutter web will replace method names so 'h' doesn't really mean anything.)Reproduction Steps to reproduce the behavior:
Expected behavior When query() is called, then an Algolia snapshot is returned with correct hits.
Desktop (please complete the following information):
Additional context / Fix I was able to fix the issue by replacing lib/src/algolia.dart: line 111
Right now it is:
I'm pretty sure that the return type should be http.Response, however json.decode is returning dynamic. I'm not 100% sure why it works in debug mode and not release, or why this fixes it. Please let me know if you need any more info.