flutter_twitter_login 1.1.0

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

flutter_twitter_login

pub package Build Status Coverage Status

A Flutter plugin for using the native TwitterKit SDKs on Android and iOS.

This plugin uses the new Gradle 4.1 and Android Studio 3.0 project setup.

Dart support

  • Dart 1: 1.0.x.
  • Dart 2: 1.1.0 and up.

Installation

See the installation instructions on pub. No platform-specific configuration is needed!

How do I use it?

Here's some sample code that should cover most of the cases. For full API reference, just see the source code. Everything is documented there.

var twitterLogin = new TwitterLogin(
  consumerKey: '<your consumer key>',
  consumerSecret: '<your consumer secret>',
);

final TwitterLoginResult result = await twitterLogin.authorize();

switch (result.status) {
  case TwitterLoginStatus.loggedIn:
    var session = result.session;
    _sendTokenAndSecretToServer(session.token, session.secret);
    break;
  case TwitterLoginStatus.cancelledByUser:
    _showCancelMessage();
    break;
  case TwitterLoginStatus.error:
    _showErrorMessage(result.error);
    break;
}

1.1.0

  • Dart 2 support! There should not be any breaking changes. Please do file issues if you have problems.

1.0.1

  • Fixed onActivityResult override that was potentially preventing other plugins from receiving Activity results.
  • Fixed a logout crash on Android in the case when the user wasn't already logged in.
  • Fixed #1 by returning NSNull from the sessionToMap method when the twitter session is nil.
  • Fix #2 by clarifying the documentation. Also explain the toMap and fromMap methods of TwitterSession more clearly.

1.0.0

  • Initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_twitter_login/flutter_twitter_login.dart';

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

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

class _MyAppState extends State<MyApp> {
  static final TwitterLogin twitterLogin = new TwitterLogin(
    consumerKey: 'kkOvaF1Mowy4JTvCxKTV5O1WF',
    consumerSecret: 'ZECGsI6UUDBEUVGkJe4S5vd0FGqGxC3wMJCgsXgPRfjSwRFnyH',
  );

  String _message = 'Logged out.';

  void _login() async {
    final TwitterLoginResult result = await twitterLogin.authorize();
    String newMessage;

    switch (result.status) {
      case TwitterLoginStatus.loggedIn:
        newMessage = 'Logged in! username: ${result.session.username}';
        break;
      case TwitterLoginStatus.cancelledByUser:
        newMessage = 'Login cancelled by user.';
        break;
      case TwitterLoginStatus.error:
        newMessage = 'Login error: ${result.errorMessage}';
        break;
    }

    setState(() {
      _message = newMessage;
    });
  }

  void _logout() async {
    await twitterLogin.logOut();

    setState(() {
      _message = 'Logged out.';
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Twitter login sample'),
        ),
        body: new Center(
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              new Text(_message),
              new RaisedButton(
                child: new Text('Log in'),
                onPressed: _login,
              ),
              new RaisedButton(
                child: new Text('Log out'),
                onPressed: _logout,
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_twitter_login: "^1.1.0"

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:flutter_twitter_login/flutter_twitter_login.dart';
  
Version Uploaded Documentation Archive
1.1.0 Mar 24, 2018 Go to the documentation of flutter_twitter_login 1.1.0 Download flutter_twitter_login 1.1.0 archive
1.0.1 Feb 24, 2018 Go to the documentation of flutter_twitter_login 1.0.1 Download flutter_twitter_login 1.0.1 archive
1.0.0 Feb 6, 2018 Go to the documentation of flutter_twitter_login 1.0.0 Download flutter_twitter_login 1.0.0 archive

Analysis

We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3
  • Flutter: 0.5.2

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
78 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
89
Learn more about scoring.

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run flutter format to format lib/flutter_twitter_login.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7
Dev dependencies
flutter_test