Google Flutter local_auth Error: no_fragment_activity

 最近在學習Google Flutter時,使用了local_auth的指紋認證package,在執行時出現下列的警告:

PlatformException(no_fragment_activity, local_auth plugin requires activity to be a FragmentActivity.,null,null)

到專案目錄底下,開啟MainActivity.kt,例如我的目錄如下:F:\Project\test01\android\app\src\main\kotlin\com\example\test01\

增加下列:
import io.flutter.embedding.android.FlutterFragmentActivity

將FlutterActivity改為FlutterFragmentActivity:

class MainActivity: FlutterActivity() {}
改成
class MainActivity: FlutterFragmentActivity() { }

重新執行即可解決。發生此原因是因為local_auth需要使用FlutterFragmentActivity類別來呈現出指紋視窗