홈 로그인 창에서 접속하고 싶은데 기존 계정으로 로그인을 시도하면 버튼이 작동하지 않고 창이 그대로 유지됩니다.
import 'package:finalproject/Pages/home.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => new _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
String _email, _password;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: Text('Sign in'),
),
body: Form(
key: _formKey,
child: Column(
children: <Widget>[
TextFormField(
validator: (input) {
if (input.isEmpty) {
return ' Write your email';
}
return null;
},
onSaved: (input) => _email = input,
decoration: InputDecoration(labelText: ' Email'),
),
TextFormField(
validator: (input) {
if (input.length < 6) {
return ' Write your password';
}
return null;
},
onSaved: (input) => _password = input,
decoration: InputDecoration(labelText: ' Password'),
obscureText: true,
),
RaisedButton(
onPressed: signIn,
child: Text('Sign in'),
),],),),);}
void signIn() async {
if (_formKey.currentState.validate()) {
_formKey.currentState.save();
try {
// ignore: deprecated_member_use
UserCredential authResult = await FirebaseAuth.instance
.signInWithEmailAndPassword(email: _email, password: _password);
final User user = authResult.user;
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Home()),
);
} catch (e) {
print(e.message);
}}}}
또한 로그인 버튼을 누르면 항상이 메시지를받습니다.
I / flutter (3130) : Firebase 앱 '[DEFAULT]'가 생성되지 않았습니다. Firebase.initializeApp ()을 호출하세요.
아마도 이것이 그 이유일까요?
FirebaseApp을 초기화해야합니다. 다음과 같이 주요 기능에서 수행 할 수 있습니다.
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다