flutter_passcode _screen
this package gives you beautiful pass code page for using both android and ios.
finger print usage
first, be sure you should ensure that you add the local_auth
package as a dependency.
https://pub.dartlang.org/packages/local_auth
ios integration
note that this plugin works with both touchid and faceid. however, to use the latter, you need to also add:
<key>nsfaceidusagedescription</key>
<string>why is my app authenticating using face id?</string>
to your info.plist file. failure to do so results in a dialog that tells the user your app has not been updated to use touchid.
android integration
update your project’s androidmanifest.xml file to include the use_fingerprint permissions:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<uses-permission android:name="android.permission.use_fingerprint"/>
<manifest>
usage
it is really easy to use!
you should ensure that you add the flutter_lock_screen
as a dependency in your flutter project.
dependencies:
flutter_lock_screen: '^1.0.5'
than you can use it with below example.
import 'package:flutter/material.dart';
import 'package:local_auth/local_auth.dart';
import 'package:testapp/empty_page.dart';
import 'package:flutter/services.dart';
class passcodescreen extends statefulwidget {
passcodescreen({key key, this.title}) : super(key: key);
final string title;
@override
_passcodescreenstate createstate() => new _passcodescreenstate();
}
class _passcodescreenstate extends state<passcodescreen> {
bool isfingerprint;
future<null> biometrics() async {
final localauthentication auth = new localauthentication();
bool authenticated = false;
try {
authenticated = await auth.authenticatewithbiometrics(
localizedreason: 'scan your fingerprint to authenticate',
useerrordialogs: true,
stickyauth: false);
} on platformexception catch (e) {
print(e);
}
if (!mounted) return;
if (authenticated) {
setstate(() {
isfingerprint = true;
});
}
}
@override
widget build(buildcontext context) {
var mypass = [1, 2, 3, 4];
return lockscreen(
title: "this is screet ",
passlength: mypass.length,
bgimage: "images/pass_code_bg.jpg",
fingerprintimage: "images/fingerprint.png",
showfingerpass: true,
fingerfunction: biometrics,
fingerverify: isfingerprint,
bordercolor: colors.white,
showwrongpassdialog: true,
wrongpasscontent: "wrong pass please try again.",
wrongpasstitle: "opps!",
wrongpasscancelbuttontext: "cancel",
passcodeverify: (passcode) async {
for (int i = 0; i < mypass.length; i++) {
if (passcode[i] != mypass[i]) {
return false;
}
}
return true;
},
onsuccess: () {
navigator.of(context).pushreplacement(
new materialpageroute(builder: (buildcontext context) {
return emptypage();
}));
});
}
}
Comments are closed.