首页 > 解决方案 > firebase auth with flutter

问题描述

Please I need help I can't connect firebase with flutter I have this problem I have this message:

Firebase: Could not find the Android Application module. Only Android Application Modules can be connected to Firebase online projects. Create a new Android Application Module or create/import a different Android Studio project.


    import 'package:flutter/material.dart';
    import 'package:firebase_auth/firebase_auth.dart';
    import 'homepage.dart';

    class LoginPage extends StatefulWidget {
    @override
   _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  String _email;
  String _password;
  GlobalKey<FormState> _keyform = GlobalKey<FormState>();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: new Text("flutter login"),
      ),
      body: new Form(
          key: _keyform,
          child: new Column(
            children: <Widget>[
              new TextFormField(
                validator: (input) {
                  if (input.isEmpty) {
                    return "saisir votre email";
                  }
                },
                onSaved: (input) => _email = input,
                decoration: InputDecoration(labelText: "email"),
              ),
              new TextFormField(
                validator: (input) {
                  if (input.length < 6) {
                    return "changer votre mot de passe";
                  }
                },
                onSaved: (input) => _password = input,
                obscureText: true,
                decoration: InputDecoration(labelText: "mot de passe"),
              ),
              RaisedButton(
                onPressed: signin,
                child: Text("envoyer"),
              )
            ],
          )),
    );
  }

  Future<void> signin() async {
    final formState = _keyform.currentState;
    if (formState.validate()) {
      formState.save();
      try {
        FirebaseUser user = await FirebaseAuth.instance
            .signInWithEmailAndPassword(email: _email, password: _password);
        Navigator.push(context,
            MaterialPageRoute(builder: (BuildContext context) {
          return new homepage();
        }));
      } catch (e) {
        print(e.message);
      }
      ;
    }
  }
}

标签: flutterfirebase-authentication

解决方案


推荐阅读