apn_fb_login 0.0.1

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

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 pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or 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.6 Dec 12, 2018 Go to the documentation of apn_fb_login 0.0.6 Download apn_fb_login 0.0.6 archive
0.0.5 Dec 12, 2018 Go to the documentation of apn_fb_login 0.0.5 Download apn_fb_login 0.0.5 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]
3
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
1
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.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.