Flutter Web release mode cannot show data from Algolia

Issue

I cannot show a list retrieved by Algolia when I am using –release mode in Flutter. It’s very interesting that it works just fine when running the app in Flutter Web Debug.
Can anyone help me out with this issue?

Works with:

[✓] Flutter Web Debug

[✓] Postman

Error I got in Web Console:

js_helper.dart:1137 Uncaught TypeError: Cannot read properties of undefined (reading 'h')
    at Object.bf4 (VM939 main.dart.js:27309:16)
    at VM939 main.dart.js:52638:25
    at b_W.a (VM939 main.dart.js:5429:62)
    at b_W.$2 (VM939 main.dart.js:46761:14)
    at aZB.$1 (VM939 main.dart.js:46755:21)
    at abu.oj (VM939 main.dart.js:47823:32)
    at aQY.$0 (VM939 main.dart.js:47180:11)
    at Object.EG (VM939 main.dart.js:5562:40)
    at av.u7 (VM939 main.dart.js:47112:3)
    at a64.dj (VM939 main.dart.js:46750:8)

Flutter Version (Channel stable, 2.10.0, on macOS 12.1 21C52 darwin-x64, locale en-US)

Snipped code:
Algolia call function:

Future<AlgoliaQuerySnapshot> getEmployee(String name) async {
    AlgoliaQuery query = algolia.instance
        .index(employeeIndexName)
        .facetFilter('companyId:${userController.user.companyId}')
        .query(name);
    AlgoliaQuerySnapshot snap = await query.getObjects();
    return snap;
  }

Reveal in list:

FutureBuilder(
              future: AlgoliaService().getEmployee(searchQuery),
              builder: (BuildContext context,
                  AsyncSnapshot<AlgoliaQuerySnapshot> snapshot) {
                if (snapshot.hasError) {
                  return Text('Something went wrong');
                }

                if (snapshot.connectionState == ConnectionState.waiting) {
                  return Center(
                    child: CircularProgressIndicator(),
                  );
                }
               return Text("No errors");
             )

Solution

I had the same issue.

In case anyone is looking for an immediate fix, what worked for me was to force the use of 1.0.2 dependency instead of 1.0.4:

dependencies:
    algolia: '1.0.2'

This is an open issue.

Answered By – Nick Khotenko

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *