apn_fb_login 0.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 0

apn_fb_login

A flutter plugin project that allows you to easily connect to Facebook and get your profile information

Setup

iOS configuration

Edit your Info.plist and add add the following:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb##APPID##</string>
        </array>
    </dict>
</array>
<key>FacebookAppID</key>
<string>##APPID##</string>
<key>FacebookDisplayName</key>
<string>##APPNAME##</string>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
</array>

Change ##APPID## and ##APPNAME##

Android configuration

None

Usage

Import the lib:

import 'package:apn_fb_login/apn_fb_login.dart';

Define a FacebookConnect object:

final _facebookConnect = new FacebookConnect(
    appId: '##APPID##',
    clientSecret: '##APPSECRET##');

Authenticate like so:

ApnFbLogin.login(_facebookConnect).then((FacebookOAuthToken token) {
  this.token = token;
}).catchError((dynamic error) {
  print(error);
});

Use the FacebookOAuthToken to get the graph/me result:

ApnFbLogin.me().then((FacebookUser user) {
  this.user = user;
}).catchError((dynamic error) {
  print(error);
});

See the project in /example for a more complete example

Flutter

For help getting started with Flutter, view our online documentation.

[0.0.1] - December 03, 2017

  • First release, basic auth and graph/me call to get FacebookUser.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:apn_fb_login/apn_fb_login.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool isloading = false;
  FacebookOAuthToken token;
  FacebookUser user;
  String data;

  /// Get your app id and secret at https://developers.facebook.com
  final _facebookConnect = new FacebookConnect(
      appId: '##APPID##',
      clientSecret: '##APPSECRET##');

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Facebook login'),
        ),
        body: _body(),
        floatingActionButton: new FloatingActionButton(
          child: new Icon(token == null ? Icons.lock_open : Icons.face),
          onPressed: () {
            if (isloading) return;

            _setResult(true, null);
            if (token == null)
              _doLogin();
            else
              _queryMe();
          },
        ),
      ),
    );
  }

  void _doLogin() {
    ApnFbLogin.login(_facebookConnect).then((FacebookOAuthToken token) {
      this.token = token;
      _setResult(false, token.toString());
    }).catchError((dynamic error) {
      print(error);
      _setResult(false, null);
    });
  }

  void _queryMe() {
    ApnFbLogin.me().then((FacebookUser user) {
      this.user = user;
      _setResult(false, user.toString());
    }).catchError((dynamic error) {
      print(error);
      _setResult(false, null);
    });
  }

  Widget _body() {
    if (this.isloading) {
      return new Center(child: new CircularProgressIndicator());
    } else if (this.user != null) {
      return new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            _textWidget("Got user!\nWelcome ${user.name}"),
            new ClipOval(child: new Image.network(this.user.avatarUrl)),
          ]);
    } else if (this.token != null) {
      return _textWidget("Authorized!\nClick again to query /me");
    } else {
      return _textWidget("Click the button to connect with Facebook");
    }
  }

  void _setResult(bool loading, String data) {
    setState(() {
      this.isloading = loading;
      this.data = data;
    });
  }

  Widget _textWidget(String text) =>
      new Container(
        padding: new EdgeInsets.all(8.0),
        child: new Center(
          child: new Text(
            text,
            textAlign: TextAlign.center,
          ),
        ),
      );

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  apn_fb_login: ^0.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:apn_fb_login/apn_fb_login.dart';
  
Version Uploaded Documentation Archive
0.0.4 Dec 29, 2017 Go to the documentation of apn_fb_login 0.0.4 Download apn_fb_login 0.0.4 archive
0.0.3 Dec 8, 2017 Go to the documentation of apn_fb_login 0.0.3 Download apn_fb_login 0.0.3 archive
0.0.2 Dec 3, 2017 Go to the documentation of apn_fb_login 0.0.2 Download apn_fb_login 0.0.2 archive
0.0.1 Dec 3, 2017 Go to the documentation of apn_fb_login 0.0.1 Download apn_fb_login 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Health issues and suggestions

Fix lib/apn_fb_login.dart. (-43.75 points)

Analysis of lib/apn_fb_login.dart failed with 2 errors:

line 18 col 59: The argument type '(Map<String, String>) → FacebookOAuthToken' can't be assigned to the parameter type '(dynamic) → FutureOr<FacebookOAuthToken>'.

line 28 col 62: The argument type '(Map<String, String>) → FacebookUser' can't be assigned to the parameter type '(dynamic) → FutureOr<FacebookUser>'.

Maintenance issues and suggestions

Add SDK constraint in pubspec.yaml. (-50 points)

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

Homepage does not exists. (-20 points)

We were unable to access https://www.appnormal.com at the time of the analysis.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8