Today I will explain the process of using local (in-built) authentication usage in Flutter.
Pre-requisites
1. pubspeck.yaml update
dependencies:local_auth: ^0.6.2+3
2. Install the packages from command line
$ flutter pub get
Note: In Visual Studio Code or Android Studio automatically by saving the pubspec.yaml file packages will get updated
Usage
1. Import the package in the respective dart file (say main.dart)
import 'package:local_auth/local_auth.dart';
2.
Troubleshooting
1. I/flutter : PlatformException(no_fragment_activity, local_auth plugin requires activity to be a FragmentActivity., null)
- Open /android/app/src/main/kotlin/../MainActivity.kt
- Update the file with following content
package com.[your.package]import androidx.annotation.NonNull;import io.flutter.embedding.android.FlutterFragmentActivityimport io.flutter.embedding.engine.FlutterEngineimport io.flutter.plugins.GeneratedPluginRegistrantclass MainActivity: FlutterFragmentActivity() {override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {GeneratedPluginRegistrant.registerWith(flutterEngine);}}
Please send your feedback and comments to psrdotcom@gmail.com
No comments:
Post a Comment