1

Unhandled Exception: 'package:realm_dart/src/helpers.dart': error: line 26 pos 3: native function 'Helpers_invokeStatic' (2 arguments) cannot be found

While starting the application its working perfectly and fetching data but when I restart the application it throws above error.

main.dart


  void ints() {
    print("initState");
    var config = new Configuration();
    config.schema.add(Car);

    var realm = new Realm(config);

    realm.write(() {
      print("realm write callback");
      var car = realm.create(new Car()..make = "Audi");
      print("The car is ${car.make}");
      car.make = "VW";
      print("The car is ${car.make}");
    });

    var objects = realm.objects<Car>();
    var indexedCar = objects[1];
    print('here');
    print("The indexedCar is ${indexedCar.make}");
  }

Configuration.dart

  add(Type type) {
    print(type);
    var schema = Helpers.invokeStatic(type, "getSchema");
    //set the static field on the T class.
    TypeStaticProperties.setValue(type, "schema", schema);
    // _generateSchema(type);
    innerList.add(type);
  }

Helpers.dart

class Helpers {
  static DateTime createDateTime(int miliseconds) {
    return DateTime.fromMillisecondsSinceEpoch(miliseconds, isUtc: true);
  }
  static dynamic invokeStatic(Type type, String name) native "Helpers_invokeStatic";
}
Vimal
  • 11
  • 2
  • Welcome to SO. The error is clear; the function `Helpers.invokeStatic` cannot be found. So your next step is to find out what that is and if it's not there, either include it or create the function. Also, the code in your question does not 'connect' to Realm. If you have more information, update the question. In the meantime, please review the following two guides on asking questions: [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Jay Apr 18 '21 at 13:36
  • Thanks for the feedback. Its running properly at the very first time while compiling when we restart the application it throwing this error. – Vimal Apr 19 '21 at 04:28
  • I don't think we will be able to help; the question and error don't appear to be related to Realm or MongoDB and the code in the question doesn't connect to Realm; it's attempting to write a Car object. Where/what is `Helpers.invokeStatic`? Is that code that exists in your app? The question really needs more information. – Jay Apr 19 '21 at 15:24
  • What is this `Helpers_invokeStatic`? – Jay Apr 20 '21 at 15:31

0 Answers0