diff --git a/android/app/src/main/kotlin/com/example/doctor_app_flutter/MainActivity.kt b/android/app/src/main/kotlin/com/example/doctor_app_flutter/MainActivity.kt
index a1025944..ce684883 100644
--- a/android/app/src/main/kotlin/com/example/doctor_app_flutter/MainActivity.kt
+++ b/android/app/src/main/kotlin/com/example/doctor_app_flutter/MainActivity.kt
@@ -4,9 +4,10 @@ import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
+import io.flutter.embedding.android.FlutterFragmentActivity
-class MainActivity: FlutterActivity() {
- override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
+class MainActivity: FlutterFragmentActivity() {
+ override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml
index 631e9b28..5b0c3265 100644
--- a/android/app/src/profile/AndroidManifest.xml
+++ b/android/app/src/profile/AndroidManifest.xml
@@ -4,4 +4,6 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
+
+
diff --git a/lib/widgets/auth/known_user_login.dart b/lib/widgets/auth/known_user_login.dart
index ebe10d88..97cb4012 100644
--- a/lib/widgets/auth/known_user_login.dart
+++ b/lib/widgets/auth/known_user_login.dart
@@ -1,10 +1,13 @@
import 'dart:collection';
+import 'dart:ffi';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:hexcolor/hexcolor.dart';
+import 'package:local_auth/local_auth.dart';
import 'package:shared_preferences/shared_preferences.dart';
DrAppSharedPreferances SharedPref = new DrAppSharedPreferances();
@@ -16,13 +19,16 @@ class KnownUserLogin extends StatefulWidget {
class _KnownUserLoginState extends State {
Future _prefs = SharedPreferences.getInstance();
+ final LocalAuthentication auth = LocalAuthentication();
+ String _authorized = "not Authorized";
+ bool _isAuthenticating = false;
Future loggedUserFuture;
var loggedUser;
Future getSharedPref() async {
SharedPref.getObj('loggedUser').then((userInfo) {
// if(loggedUser == null){}
loggedUser = userInfo;
- print('dddddddddddddddd${loggedUser}');
+ // print('dddddddddddddddd${loggedUser}');
});
}
@@ -41,7 +47,6 @@ class _KnownUserLoginState extends State {
return FutureBuilder(
future: loggedUserFuture,
builder: (BuildContext context, AsyncSnapshot snapshot) {
- print('SnapShot ${snapshot}');
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return DrAppCircularProgressIndeicator();
@@ -151,16 +156,14 @@ class _KnownUserLoginState extends State {
child: Column(
children: [
RaisedButton(
- onPressed: () {
- silentLogin();
- },
+ onPressed:_authenticate,
elevation: 0.0,
child: Container(
width: double.infinity,
height: 50,
child: Center(
child: Text(
- "Verify using FingerPRint".toUpperCase(),
+ "Verify using FingerPRint ${_authorized}".toUpperCase(),
// textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
@@ -207,7 +210,50 @@ class _KnownUserLoginState extends State {
Navigator.of(context).pushNamed('routeName');
}
- silentLogin(){
-
+ silentLogin() {
+ _authenticate();
+ }
+
+
+ Future _authenticate() async {
+ _getAvailableBiometrics();
+ bool authenticated = false;
+ try {
+ setState(() {
+ _isAuthenticating = true;
+ _authorized = 'Authenticating';
+ });
+ authenticated = await auth.authenticateWithBiometrics(
+ localizedReason: 'Scan your fingerprint to authenticate',
+ useErrorDialogs: true,
+ stickyAuth: true);
+ setState(() {
+ _isAuthenticating = false;
+ _authorized = 'Authenticating';
+ });
+ } on PlatformException catch (e) {
+ print(e);
+ }
+ if (!mounted) return;
+
+ final String message = authenticated ? 'Authorized' : 'Not Authorized';
+ setState(() {
+ print('_authorized'+_authorized);
+ _authorized = message;
+ });
+ }
+
+ Future _getAvailableBiometrics() async {
+ List availableBiometrics;
+ try {
+ availableBiometrics = await auth.getAvailableBiometrics();
+ } on PlatformException catch (e) {
+ print(e);
+ }
+ if (!mounted) return;
+
+ setState(() {
+ print('availableBiometrics $availableBiometrics');
+ });
}
}
diff --git a/pubspec.lock b/pubspec.lock
index 8ae7ebe2..dd48d165 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -209,6 +209,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
+ flutter_plugin_android_lifecycle:
+ dependency: transitive
+ description:
+ name: flutter_plugin_android_lifecycle
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.6"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -317,6 +324,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
+ local_auth:
+ dependency: "direct main"
+ description:
+ name: local_auth
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.6.1+3"
logging:
dependency: transitive
description:
@@ -394,6 +408,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
+ platform:
+ dependency: transitive
+ description:
+ name: platform
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.2.1"
pool:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index e9a7512d..5270034c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -28,6 +28,7 @@ dependencies:
shared_preferences: ^0.5.6+3
imei_plugin: ^1.1.6
flutter_flexible_toast: ^0.1.4
+ local_auth: ^0.6.1+3