我正在尝试学习如何获取Flutter应用程序以登录Firebase身份验证。我使用android studio插件创建了一个新的flutter项目,并从firebase_auth页面添加了依赖项和代码。
尝试在FirebaseAuth.instance(_auth)中调用方法时,出现错误“未为类'FirebaseAuth'定义方法'signInWithGoogle'”。这是代码:
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:firebase_auth/firebase_auth.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning …Run Code Online (Sandbox Code Playgroud)