Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3d-party library injection #2

Open
wasylews opened this issue Nov 4, 2018 · 1 comment
Open

3d-party library injection #2

wasylews opened this issue Nov 4, 2018 · 1 comment

Comments

@wasylews
Copy link

wasylews commented Nov 4, 2018

Hello, I don't know if it's related to dryice or more to reflectable. But how can I inject class from another package?
Here is the code:

import 'package:dryice/dryice.dart';
import 'package:flutter_facebook_login/flutter_facebook_login.dart';

@inject
class FacebookService {

  FacebookLogin facebookLogin;

  @inject
  FacebookService(this.facebookLogin);

  Future<String> login() async {
    FacebookLoginResult result = await facebookLogin.logInWithReadPermissions(['email']);
    switch (result.status) {
      case FacebookLoginStatus.loggedIn:
        return Future.value(result.accessToken.token);
      case FacebookLoginStatus.error:
        return Future.error(new Exception(result.errorMessage));
      case FacebookLoginStatus.cancelledByUser:
        return Future.error(new Exception("Cancelled by user"));
    }
    // doesn't go here
    return null;
  }

And when i'm starting an app I get an exception:

E/flutter (24038): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter (24038): Reflecting on type 'FacebookLogin' without capability
@HerrNiklasRaab
Copy link

This should work:

@inject
class FirestoreWrapper {
  Firestore firestore;
  FirestoreWrapper(this.firestore);
}

bind(FirestoreWrapper).toInstance(FirestoreWrapper(firestore));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants