flutterdartvisibilityimporterrorbackendless

Indirectly exported class not visible


I'm having trouble using the Backendless plugin for Flutter.

I include

import 'package:backendless_sdk/backendless_sdk.dart';

(as per the instructions) and can then use e.g. Backendless.UserService. But if I try to generate a user to register, e.g.:

    var user = new BackendlessUser();
    user.setEmail("info@example.org");
    user.setPassword("password");
    Backendless.UserService.register(user);

I get an error Undefined class 'BackendlessUser' on the first line. This class is defined in src/modules/user_service.dat, which is exported by src/modules/modules.dartlike this:

library modules;

export 'cache.dart';
...
export 'user_service.dart';

which in turn is imported by backendless_sdk.dart like this:

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

I would have thought that it would get imported indirectly by the import of backendless_sdk.dart, but apparently not. When I import it explicitly (with the same import statement, but now in my own code and not just indirectly in backendless_sdk.dart), I get a warning Don't import implementation files from another package. But it's not an implementation file; it's exported as part of the public API (at least that's what I understand the export statement to mean).

The Dart tutorial for creating packages suggests to place the export statements directly under lib, not in lib/src, so I'm wondering whether this is an error in the structure of the plugin, or whether I'm doing something wrong.

I'd be grateful both for a solution to this particular problem and also for pointers to how I can better understand packages, libraries, imports and exports in dart; unfortunately I don't find the language specification particularly helpful in this regard.

(The error and the warning are the same whether I use flutter analyze or IntelliJ IDEA.)


Solution

  • The problem has been fixed in the 0.0.3 version of the plugin. Please update the backendless_sdk version in your pubspec.yaml.

    You can include the only one import now:

    import 'package:backendless_sdk/backendless_sdk.dart';
    

    Please also note, that there are some changes in the syntax. So for your example you should use:

    var user = new BackendlessUser()
      ..email = "info@example.org"
      ..password = "password";
    Backendless.userService.register(user);