Application constructor

Application(
  1. String schema,
  2. String server,
  3. int port,
  4. String topic,
  5. String appKey, {
  6. Key? key,
  7. required Widget child,
  8. bool pushSubscribe = false,
})

Implementation

Application(
    String schema, String server, int port, String topic, String appKey,
    {Key? key, required super.child, this.pushSubscribe = false})
    : _client = AppHttpClient(appKey, schema, server, port),
      super(key: key) {
  _topic = topic;
  SharedPreferences.getInstance().then((prefs) {

    Isolate.spawn(pushHandle, PushIsolateModel(DbPlatform.getDeviceId(prefs), schema, server, port ));

    var token = prefs.getString("token");
    if (token != null) {
      _client.setAuthHeader(prefs.getString("token"));
      User(_client).fetchUser().then((user) {
        _user = user;
        _client.registerDevice(prefs, userId: user.id);
      });
    } else {
      _client.registerDevice(prefs);
    }
  });
}