flutter_reprint 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 64

flutter_reprint #

A plugin that allows you to use Reprint in Flutter apps.

Installing #

To use this plugin, follow the steps below:

  1. add flutter_reprint as a dependency in your pubspec.yaml file.

  2. add Reprint as a dependency in your your_flutter_app_main_dir/android/app/build.gradle file:

dependencies {    
    (...) 
    implementation 'com.github.ajalt.reprint:core:3.3.2@aar'
} 
  1. Add Reprint.initialize(this) to your application class onCreate method:
class YourApplication : FlutterApplication() {    
    
 override fun onCreate() {   
     super.onCreate()  
     Reprint.initialize(this) }    
 } 

If you do not have an application class, you'll need to create one. Don't forget to add it to your AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"    
 package="br.com.marcoporcho.my_app">    
   
 <application android:name=".application.YourApplication"   
 (...)  
 > 
  1. Add the USE_FINGEPRINT permission to your AndroidManifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"    
 package="br.com.marcoporcho.my_app">    
<uses-permission android:name="android.permission.USE_FINGERPRINT" /> 

Getting Started #

You can check out the example directory for a sample app using flutter_reprint.

For the impatient:

Check if the device has fingerprint hardware

 bool fingerprintReaderAvailable = await FlutterReprint.canCheckFingerprint;

Authenticate

 FlutterReprint.authenticateWithBiometrics().then((authResult) { 
	if(authResult.success) {
		 print('SUCCESS');
	} else {
	 print('FAIL');
	}
});

Stop authentication

 FlutterReprint.stopAuthentication().then((cancelOK) { 
	if(cancelOK) {
		 print('SUCCESS');
	} else {
	 print('FAIL');
	}
});

Changelog #

1.0.3 #

  • Removing initialization (must be done in the android code of the project this plugin is used)

1.0.2 #

  • Fixing iOS building (project that use flutter_reprint would miss this plugin podspec when trying to compile it in XCode)

1.0.1 #

  • Minor code changes
  • Fixing plugin description

1.0.0 #

  • Initial release

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutter_reprint/flutter_reprint.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _fingerprintReaderAvailable = "NO";
  String _authStatus = '';
  bool isErrorMessage = false;

  TextStyle authMessageStyle,
      regularAuthMessageStyle = TextStyle(
    color: Colors.indigoAccent,
  );

  TextStyle errorAuthMessageStyle = TextStyle(
    color: Colors.red,
    fontWeight: FontWeight.bold,
  );

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String fingerprintReaderAvailable;

    try {
      fingerprintReaderAvailable =
          (await FlutterReprint.canCheckFingerprint) ? 'YES' : 'NO';
    } on PlatformException {
      fingerprintReaderAvailable = "ERROR";
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _fingerprintReaderAvailable = fingerprintReaderAvailable;
    });
  }

  _updateAuthMessage(String message, {bool isError = false}) {
    setState(() {
      _authStatus = message;
      authMessageStyle =
          isError ? errorAuthMessageStyle : regularAuthMessageStyle;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('flutter_reprint example app'),
        ),
        body: Center(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: ListView(
              children: <Widget>[
                Center(
                  child: Text(
                      'Fingerprint reader available: $_fingerprintReaderAvailable\n'),
                ),
                RaisedButton(
                  child: Text(
                    'Authenticate',
                  ),
                  onPressed: () async {
                    _updateAuthMessage('Waiting for fingerprint');

                    FlutterReprint.authenticateWithBiometrics()
                        .then((authResult) {
                      _updateAuthMessage(
                          authResult.success
                              ? "SUCCESS"
                              : "FAILED: ${authResult.failureReason}",
                          isError: !authResult.success);
                    });
                  },
                ),
                RaisedButton(
                    child: Text(
                      'Stop authentication',
                    ),
                    onPressed: () {
                      try {
                        FlutterReprint.stopAuthentication().then((cancelOK) {
                          _updateAuthMessage(cancelOK
                              ? "Authentication stopped"
                              : "Authentication was not happening");
                        });
                      } on PlatformException catch (e) {
                        _updateAuthMessage(e.message, isError: true);
                      }
                    }),
                Center(
                  child: Text(
                    _authStatus,
                    style: authMessageStyle,
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_reprint: ^1.0.3

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_reprint/flutter_reprint.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
27
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform ios

Because of import path [package:flutter_reprint/flutter_reprint.dart] that declares support for platforms: android

Package does not support Flutter platform linux

Because of import path [package:flutter_reprint/flutter_reprint.dart] that declares support for platforms: android

Package does not support Flutter platform macos

Because of import path [package:flutter_reprint/flutter_reprint.dart] that declares support for platforms: android

Package does not support Flutter platform web

Because of import path [package:flutter_reprint/flutter_reprint.dart] that declares support for platforms: android

Package does not support Flutter platform windows

Because of import path [package:flutter_reprint/flutter_reprint.dart] that declares support for platforms: android

Package not compatible with SDK dart

because of import path [flutter_reprint] that is in a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test