Search code examples
flutterdartflutter-webdart-html

Dart: NoSuchMethodError - method not found "h" on null


I am using Flutter Web and when accessing a FutureBuilder I get the NoSuchMethodError - method not found "h" on null When inspecting the page, i see the following error:

core_patch.dart:195 Uncaught TypeError: Cannot read properties of undefined (reading 'h')
    at Object.bax (VM5 main.dart.js:25360:16)
    at VM5 main.dart.js:45250:25
    at aWT.a (VM5 main.dart.js:3607:62)
    at aWT.$2 (VM5 main.dart.js:39703:14)
    at aVB.$1 (VM5 main.dart.js:39697:21)
    at a8Y.nJ (VM5 main.dart.js:40765:32)
    at aN8.$0 (VM5 main.dart.js:40122:11)
    at Object.Ds (VM5 main.dart.js:3740:40)
    at ax.tk (VM5 main.dart.js:40054:3)
    at a3F.dm (VM5 main.dart.js:39692:8)

It looks like an error from Dart js. I have update my flutter version to 2.10, but previously I had the same error, except that instead of "h" I got "i" (NoSuchMethodError - method not found "i")

P.S. I get this error ONLY in production(release) build, using debug build everything works just fine.

Code Snipped

FutureBuilder(
 future: AlgoliaService().getEmployees(searchQuery),
 builder: (BuildContext context, 
    AsyncSnapshot<AlgoliaQuerySnapshot> snapshot) {
        if (snapshot.hasError) {
             return Text("Error:  ${snapshot.error}"); // Error happens here
           }
    
        if (snapshot.connectionState == ConnectionState.waiting) {
            return Center(child: CircularProgressIndicator(),);}

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.