flutter_id4me_login 0.3.0

Basic Utils #

A dart package for many helper methods fitting different situations.

Table of Contents #

  1. Install
  2. Import
  3. Usage
  4. Changelog
  5. Copyright and license

Install #

pubspec.yaml #

Update pubspec.yaml and add the following line to your dependencies.

dependencies:
  flutter_id4me_login: ^0.3.0

Import #

Import the package with :

import 'package:flutter_id4me_login/flutter_id4me_login.dart';

Usage #

To integrate the Id4me login into your app, add the Id4meLoginButton inside your app.

Id4meLoginButton(
  properties,
  claimsParameters,
  "assets/img/id4meloginbtn.png",
  (Map<String, dynamic> userInfo) => Navigator.push(context,MaterialPageRoute(builder: (context) => Home(userInfo))),
  () => print("Error while login")
)

The tap on the button will trigger a small dialog/modal with a input field for the id4me login data. The tap on the "Login" button will then trigger the id4me login flow.

Button parameters #

NameTypeRequiredDescription
propertiesMap<String,dynamic>XThe Id4me properties
claimsParametersMap<String,dynamic>XThe Id4me claimsparameters
imageLocationStringXThe location of the image for the button
onSuccessFunction(Map<String,dynamic>)XFunction to call after successfull login
onErrorFunction()XFunction to call after failed login
heightdoubleThe height of the button. Default = 45
inputDecorationInputDecorationThe InputDecoration for domain input widget
loginBtnTextStringThe text for the login button. Default = Login
cancelBtnTextStringThe text for the cancel button. Default = Cancel
modalHintTextStringAn additional hint text, displayed in the modal

Changelog #

For a detailed changelog, see the CHANGELOG.md file

View LICENSE

Changelog #

[0.3.0] - 2019-05-10

  • Improve customization

[0.2.0] - 2019-05-08

  • Improve documentation and add example

[0.1.0] - 2019-05-08

  • Initial release

example/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_id4me_login/flutter_id4me_login.dart';
import 'package:id4me_relying_party_api/id4me_relying_party_api.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Id4me Demo Login',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Login(title: 'Id4me Demo Login'),
    );
  }
}

class Login extends StatefulWidget {
  Login({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _LoginState createState() => _LoginState();
}

class _LoginState extends State<Login> {
  Map<String, dynamic> properties = {
    Id4meConstants.KEY_CLIENT_NAME: "ID4me Demo",
  };

  Map<String, dynamic> claimsParameters = {
    "name": {"required": true, "reason": "Displayname in the user data"},
  };

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color.fromRGBO(0, 122, 157, 1),
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Image.asset("assets/img/logo.png"),
            Id4meLoginButton(
                properties,
                claimsParameters,
                "assets/img/id4meloginbtn.png",
                (Map<String, dynamic> userInfo) => Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Home(userInfo))),
                () => print("Error while login")),
          ],
        ),
      ),
    );
  }
}

class Home extends StatelessWidget {
  final String title = "Home";
  final Map<String, dynamic> userInfo;

  Home(this.userInfo);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Center(
          child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
            Text(
              "Welcome",
              style: Theme.of(context).textTheme.headline,
            ),
            SizedBox(height: 10),
            Text(userInfo["name"] + "(" + userInfo["email"] + ")",
                style: Theme.of(context).textTheme.subhead),
            SizedBox(height: 10),
            Text("Your login was successfull!\n Thank you for using Id4me.",
                style: Theme.of(context).textTheme.body1)
          ])),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_id4me_login: ^0.3.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


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

We analyzed this package on Aug 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (id4me_relying_party_api).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_webview_plugin ^0.3.4 0.3.7
id4me_relying_party_api ^0.4.0 0.4.0 0.5.0
Transitive dependencies
async 2.3.0
basic_utils 1.6.0
built_collection 4.2.2
built_value 6.7.0
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
crypto 2.1.1+1
crypto_keys 0.1.0
fixnum 0.10.9
http 0.12.0+2
http_parser 3.1.3
jose 0.1.2
json_annotation 2.4.0 3.0.0
logging 0.11.3+2
matcher 0.12.5
meta 1.1.6 1.1.7
path 1.6.4
pedantic 1.8.0+1
pointycastle 1.0.1
quiver 2.0.5
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
uuid 2.0.2
vector_math 2.0.8
Dev dependencies
flutter_test