flutter_linkedin_login 2.1.0 copy "flutter_linkedin_login: ^2.1.0" to clipboard
flutter_linkedin_login: ^2.1.0 copied to clipboard

discontinued
outdated

A Flutter plugin for allowing users to authenticate with LinkedIn and getting the user's basic profile

example/lib/main.dart

import 'dart:async';

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

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

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

typedef Future<void> FutureCallBack();

class _MyAppState extends State<MyApp> {
  String _loginStatus = 'Press button to log in';

  _signInWithLinkedIn() async {
    _callPlatformService(() async {
      String status = await FlutterLinkedinLogin.loginBasic();
      setState(() {
        _loginStatus = status;
      });
    });
  }

  _getProfile() async {
    _callPlatformService(() async {
      LinkedInProfile profile = await FlutterLinkedinLogin.getProfile();
      debugPrint("profile: $profile");
      setState(() {
        _loginStatus = profile.firstName;
      });
    });
  }

  _logout() async {
    _callPlatformService(() async {
      String status = await FlutterLinkedinLogin.logout();
      debugPrint("logout status: $status");
      setState(() {
        _loginStatus = status;
      });
    });
  }

  _callPlatformService(FutureCallBack callback) async {
    try {
      await callback();
    } on PlatformException catch(e) {
      debugPrint("PlatformException code: ${e.code}, message: ${e.message}, toString: ${e.toString()}");
      setState(() {
        _loginStatus = "code: ${e.code}, message: ${e.message}";
      });
    } catch (error) {
      debugPrint("error: $error");
    }
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('LinkedIn Login Plugin Example'),
        ),
        body: Center(
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: <Widget>[
              new Text('Login status: $_loginStatus\n'),
              new RaisedButton(
                onPressed: () => _signInWithLinkedIn(),
                child: new Text("Log into LinkedIn"),
              ),
              new LinkedInSignInButton(onSignIn: (profile, ex) {
                if (profile != null) {
                  debugPrint("profile: $profile");
                  setState(() {
                    _loginStatus = profile.firstName;
                  });
                } else {
                  debugPrint("exception: $ex");
                  setState(() {
                    _loginStatus = "code: ${ex.code}, message: ${ex.message}";
                  });
                }
              },),
              new RaisedButton(
                onPressed: _getProfile,
                child: new Text("Get Profile"),
              ),
              new RaisedButton(
                onPressed: _logout,
                child: new Text("Clear Session"),
              )
            ]
          ),
        ),
      ),
    );
  }
}
0
likes
0
pub points
32%
popularity

Publisher

unverified uploader

A Flutter plugin for allowing users to authenticate with LinkedIn and getting the user's basic profile

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_linkedin_login