1

I am following this article How to Create a Chat App with Backendless SDK for Flutter

import 'package:flutter/material.dart';
import 'package:backendless_sdk/backendless_sdk.dart'; 
import 'package:backendless_sdk/src/modules/modules.dart';

There is a error:

"Target of URI doesn't exist: 'package:backendless_sdk/src/modules/modules.dart'."

The modules.dart import is required for Backendless.Messaging, but without the import there is an error:

The getter 'Messaging' isn't defined for the type 'Backendless'.

  void initListeners() async {
    Channel channel = await Backendless.Messaging.subscribe("myChannel");
    channel.addMessageListener(onMessageReceived);
  }

pub spec.yaml

dependencies:
  flutter:
    sdk: flutter
  backendless_sdk: ^1.1.8

How can I import the Messaging module?

dak
  • 339
  • 6
  • 21

3 Answers3

1

You should change from:

await Backendless.Messaging.subscribe

in to:

await Backendless.messaging.subscribe
                  ^
                  |
           small "m" here

Versions

I checked backendless_sdk: ^0.0.2 (from tutorial) and backendless_sdk: ^1.1.8 (newest one), and in both cases this field was named messaging (lowercase).

Class Backendless

backendless_sdk-1.1.8/lib/src/backendless.dart:

enter image description here

Community
  • 1
  • 1
Boken
  • 4,825
  • 10
  • 32
  • 42
  • Indeed, the article was written for a pre-release version of the SDK. The documentation uses lower-case "m": https://backendless.com/docs/flutter/pubsub_establish_subscription.html – Mark Piller May 16 '20 at 01:08
0

It look like you are missing the installation step.

  • From the terminal: Run flutter pub get.

OR

  • From Android Studio/IntelliJ: Click Packages get in the action ribbon at the top of pubspec.yaml.
  • From VS Code: Click Get Packages located in right side of the action ribbon at the top of pubspec.yaml.
Haniel Baez
  • 1,646
  • 14
  • 19
  • Remove `import 'package:backendless_sdk/src/modules/modules.dart';` – Haniel Baez May 15 '20 at 21:17
  • Don't import implementation files from another package. Target of URI doesn't exist: 'package:backendless_sdk/src/modules/modules.dart'. Try creating the file referenced by the URI, or Try using a URI for a file that does exist – dak May 15 '20 at 21:18
  • import 'package:backendless_sdk/src/modules/modules.dart' is required for Backendless.Messaging.subscribe("myChannel"); – dak May 15 '20 at 21:19
  • There is not reference about it on https://pub.dev/packages/backendless_sdk, no even in the article you are following. – Haniel Baez May 15 '20 at 21:25
  • This is a link to the source code for the article: https://github.com/4lfant/messaging_app/blob/master/lib/main.dart – dak May 15 '20 at 21:32
  • The article that is using `backendless_sdk: ^0.0.2` from May 13, 2019, and you are using `backendless_sdk: ^1.1.8`, please use as a reference https://pub.dev/documentation/backendless_sdk/latest/ – Haniel Baez May 15 '20 at 21:44
0

I do not see any references to modules.dart in the article you mentioned. You need to import backendless_sdk and also include the socket.io dependency:

dependencies {
   implementation ('io.socket:socket.io-client:1.0.0') { 
     // excluding org.json which is provided by Android 
     exclude group: 'org.json', module: 'json' 
   }
}
Mark Piller
  • 1,046
  • 1
  • 7
  • 6
  • This is a link to the source code for the article: github.com/4lfant/messaging_app/blob/master/lib/main.dart – dak May 15 '20 at 21:59