在flutter中配置local_auth插件 [英] configure local_auth plugin in flutter
本文介绍了在flutter中配置local_auth插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的项目,使用kotlin,当我想使用Local_auth插件时,出现以下错误:
My project , uses kotlin and when I want to use Local_auth plugin , I get the error below:
PlatformException(no_fragment_activity, local_auth plugin requires activity to be a FragmentActivity., null)
local_auth的示例说的是:
what the example of local_auth says , is:
package io.flutter.plugins.localauthexample;
import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.localauth.LocalAuthPlugin;
public class MainActivity extends FlutterFragmentActivity {
// TODO(bparrishMines): Remove this once v2 of GeneratedPluginRegistrant rolls to stable. https://github.com/flutter/flutter/issues/42694
@Override
public void configureFlutterEngine(FlutterEngine flutterEngine) {
flutterEngine.getPlugins().add(new LocalAuthPlugin());
}
}
和
package io.flutter.plugins.localauthexample;
import android.os.Bundle;
import io.flutter.app.FlutterFragmentActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class EmbeddingV1Activity extends FlutterFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
但问题是我不知道Kotlin而且我不知道如何创建我的kotlin文件。
but the problem is that I don't know kotlin and I don't know how to create my kotlin file.
另外,我猜(我不确定),这可能是新版中出现抖动的错误
also , I guess (I am not sure) that , it can be a bug of flutter in its new release.
推荐答案
将 MainActivity.kt 文件的代码更改为此
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterFragmentActivity() {
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
这篇关于在flutter中配置local_auth插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文