flutter_slack_oauth 0.1.1

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

pub package

flutter_slack_oauth

A flutter OAuth package for Slack with a beautiful "Sign in with Slack" button.

Extensions:

Usage

To use this plugin, add flutter_slack_oauth as a dependency in your pubspec.yaml file.

Example

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

void main() {
  runApp(new MaterialApp(
    home: new Scaffold(
      body: new Builder(
        builder: (BuildContext context) {
          return new Center(
            child: new SlackButton(
              clientId: "XXX_CLIENT_ID_XXX",
              clientSecret: "XXX_CLIENT_SECRET_XXX",
              redirectUrl: "https://kunstmaan.github.io/flutter_slack_oauth/success.html",
              onSuccess: () async {
                String accessToken = await Token.getLocalAccessToken();
                UserList users = await slack.getUsers(accessToken);
                
                Scaffold.of(context).showSnackBar(new SnackBar(
                  content: new Text('We found ' + users.users.length.toString() + " users"),
                ));
              },
              onFailure: () {
                Scaffold.of(context).showSnackBar(new SnackBar(
                  content: new Text('Slack Login Failed'),
                ));
              },
              onCancelledByUser: () {
                Scaffold.of(context).showSnackBar(new SnackBar(
                  content: new Text('Slack Login Cancelled by user'),
                ));
              },
            ),
          );
        },
      ),
    ),
  ));
}

Don't want to use the bundled OAuth flow?

  • You can also provide your own custom onTap behaviour by manually importing package:flutter_slack_oauth/oauth/generic_slack_button.dart.
  • Or check out flutter_slack_oauth_firebase, where we use the generic_slack_button to integrate with Firebase Auth and Cloud Firestore.

[0.1.1] - 10 April 2018

  • BREAKING - Required for Flutter Beta 2
  • Required changes to support Dart 2 (and Flutter Beta 2).

[0.1.0] - 30 March 2018

  • SlackButton now uses a GenericSlackButton which is not exposed by default.
  • GenericSlackButton can have a custom onTap callback so you can hook up your custom logic, such as binding Firebase Auth.
  • To use GenericSlackButton, you need to manually import package:flutter_slack_oauth/oauth/generic_slack_button.dart, it is not exposed by default.

[0.0.5] - 29 March 2018

  • Formatted with dartfmt

[0.0.4] - 19 March 2018

  • Slack WebView now has action bar so back behaviour is possible on iOS

[0.0.2] - 19 March 2018

  • Initial release
  • Provides a SlackButton widget which is styled like an official "Sign in with Slack" button.
  • Clicking a SlackButton starts a WebView, allowing the user to log in with Slack.
  • SlackButton requires a client id, client secret, and 3 callbacks: onSuccess, onFailure, and onCancelledByUser.
  • The resulting access token is stored in shared preferences (Android) and NSUserDefaults (iOS) (thanks https://github.com/flutter/plugins/tree/master/packages/shared_preferences)
  • Basic /api/users.identity call as PoC.
  • Basic /api/users.list call as PoC.

example/lib/main.dart

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

import 'package:flutter_slack_oauth/oauth/slack.dart' as slack;

void main() {
  runApp(new MaterialApp(
    home: new Scaffold(
      appBar: new AppBar(
        title: new Text("Slack OAuth Example"),
      ),
      body: new Builder(
        builder: (BuildContext context) {
          return new Center(
            child: new SlackButton(
              clientId: "XXX_CLIENT_ID_XXX",
              clientSecret: "XXX_CLIENT_SECRET_XXX",
              redirectUrl:
                  "https://kunstmaan.github.io/flutter_slack_oauth/success.html",
              onSuccess: () async {
                String accessToken = await Token.getLocalAccessToken();
                UserList users = await slack.getUsers(accessToken);

                Scaffold.of(context).showSnackBar(new SnackBar(
                      content: new Text('We found ' +
                          users.users.length.toString() +
                          ' users'),
                    ));
              },
              onFailure: () {
                Scaffold.of(context).showSnackBar(new SnackBar(
                      content: new Text('Slack Login Failed'),
                    ));
              },
              onCancelledByUser: () {
                Scaffold.of(context).showSnackBar(new SnackBar(
                      content: new Text('Slack Login Cancelled by user'),
                    ));
              },
            ),
          );
        },
      ),
    ),
  ));
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_slack_oauth: "^0.1.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:flutter_slack_oauth/flutter_slack_oauth.dart';
  
Version Uploaded Documentation Archive
0.1.1 Apr 10, 2018 Go to the documentation of flutter_slack_oauth 0.1.1 Download flutter_slack_oauth 0.1.1 archive
0.1.0 Mar 30, 2018 Go to the documentation of flutter_slack_oauth 0.1.0 Download flutter_slack_oauth 0.1.0 archive
0.0.5 Mar 29, 2018 Go to the documentation of flutter_slack_oauth 0.0.5 Download flutter_slack_oauth 0.0.5 archive
0.0.4 Mar 19, 2018 Go to the documentation of flutter_slack_oauth 0.0.4 Download flutter_slack_oauth 0.0.4 archive
0.0.3 Mar 19, 2018 Go to the documentation of flutter_slack_oauth 0.0.3 Download flutter_slack_oauth 0.0.3 archive
0.0.2 Mar 19, 2018 Go to the documentation of flutter_slack_oauth 0.0.2 Download flutter_slack_oauth 0.0.2 archive
0.0.1 Mar 19, 2018 Go to the documentation of flutter_slack_oauth 0.0.1 Download flutter_slack_oauth 0.0.1 archive

Analysis

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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

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

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • The description is too short.

    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-v1 release.

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

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Strong-mode analysis of lib/oauth/model/user.dart gave the following hint:

    line: 9 col: 51
    'retype' is deprecated and shouldn't be used.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
flutter_webview_plugin ^0.1.5 0.1.6
http ^0.11.3+16 0.11.3+16
shared_preferences ^0.4.1 0.4.2
Transitive dependencies
async 2.0.7
charcode 1.1.1
collection 1.14.6 1.14.10
http_parser 3.1.2
meta 1.1.5
path 1.6.0 1.6.1
sky_engine 0.0.99
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
vector_math 2.0.6 2.0.7
Dev dependencies
test ^0.12.0