当前位置: 首页 > 知识库问答 >
问题:

带火基的埃罗

连坚白
2023-03-14

我是新来的。Im尝试连接firebase,在屏幕登录中验证电子邮件和密码。

代码:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:login/page.dart';
import 'package:login/register_page.dart';
import 'package:firebase_auth/firebase_auth.dart';

import 'forgivePassword.dart';

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _email, _password;
  final GlobalKey<FormState> _formKey = GlobalKey<FormState>();


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.blue,
      body: Center(
        child: SizedBox(
          width: 380,
          height: 400,
          child: Form(
            key: _formKey,
            child: Card(
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(20.0)
              ),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Container(
                    padding: EdgeInsets.only(top: 10.0),
                  ),
                  Container(
                    padding: EdgeInsets.fromLTRB(50.0, 1.0, 50.0, 1.0),
                    child: TextFormField(
                      validator: (input){
                        if(input.isEmpty){
                          return ;
                        }
                      },
                      onSaved: (input) => _email = input,
                      keyboardType: TextInputType.emailAddress,
                      decoration: InputDecoration(
                        labelText: "E-mail",
                        border: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(20.0))
                        )
                      ),
                    ),
                  ),

                  Container(
                    padding: EdgeInsets.only(top: 10.0),
                  ),
                  Container(
                    padding: EdgeInsets.fromLTRB(50.0, 1.0, 50.0, 0.0),
                    child: TextFormField(
                      validator: (input){
                        if(input.length < 6){
                          return 'Your password needs to be atleast 6 characters';
                        }
                      },
                      onSaved: (input) => _password = input,
                      obscureText: true,
                      decoration: const InputDecoration(
                          labelText: "Password",
                          border: OutlineInputBorder(
                              borderRadius: BorderRadius.all(Radius.circular(20.0)))),
                      keyboardType: TextInputType.emailAddress,
                    ),
                  ),
                  Row(
                    children: [
                      Padding(
                        padding: const EdgeInsets.fromLTRB(178, 0, 0, 0),
                        child: TextButton(
                            onPressed: () {
                              Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                      builder: (BuildContext context) =>
                                          ForgivePassword()));
                            },
                            child: Text(
                              "Esqueci minha senha",
                              style: TextStyle(
                                color: Colors.blue,
                                decoration: TextDecoration.underline,
                              ),
                            )),
                      )
                    ],
                  ),
                  SizedBox(
                      width: 310,
                      height: 35,
                      child: RaisedButton(
                        color: Colors.blue,
                        textColor: Colors.white,
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(20.0),
                        ),
                        onPressed: sigIn,
                        child: Text("Login"),
                      )),
                  Padding(
                    padding: const EdgeInsets.only(top: 15.0),
                    child: SizedBox(
                        width: 310,
                        height: 35,
                        child: RaisedButton(
                          color: Colors.blue,
                          textColor: Colors.white,
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(20.0),
                          ),
                          onPressed: () {
                            Navigator.push(
                                context,
                                MaterialPageRoute(
                                    builder: (BuildContext context) =>
                                        PaginaRegistro()));
                          },
                          child: Text("Registre-se"),
                        )),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
  Future<void> sigIn() async{
    final formState = _formKey.currentState;
    if(formState.validate()){
      try{
        UserCredential user =  await FirebaseAuth.
        instance.signInWithEmailAndPassword(email: _email, password: _password);
        Navigator.push(context, MaterialPageRoute(builder: (context) => Home()));
      }catch(e){
        print(e.massage);
      }
    }
  }
}

错误:

正在执行热重启。。。正在将文件同步到IA Emulator上的设备AOSP。。。在925ms内重新启动应用程序。E/flatter(4428):[ERROR:flatter/lib/ui/ui\u dart\u state.cc(186)]未处理的异常:NoSuchMethodError:类“FirebaseException”没有实例getter“按摩”。E/flatter(4428):接收器:“FirebaseException”的实例E/flatter(4428):尝试调用:按摩E/flatter(4428):#0对象。无此方法(dart:core patch/object_patch.dart:54:5)E/颤振(4428):#1
\u MyAppState。sigIn(软件包:login/login_page.dart:149:17)E/flatter(4428):#2__handleTap(包装:flatter/src/material/ink_well.省道:991:20)E/flatter(4428):#3手势识别器。调用Callback(软件包:flatter/src/signatures/recognizer.dart:182:24)E/flatter(4428):#4个TapGestureCongnizer。handleTapUp(套装:flatter/src/signatures/tap.dart:598:11)E/flatter(4428):#5
BaseTapgestureRecognitor_检查(软件包:flift/src/signatures/tap.dart:287:5)E/flift(4428):#6
BaseTapgestureRecognitor。handlePrimaryPointer(软件包:flatter/src/signatures/tap.dart:222:7)E/flatter(4428):#7
PrimaryPointer检测识别器。handleEvent(套装:flatter/src/signatures/recognizer.dart:475:9)E/flatter(4428):#8点外部_调度(程序包:flatter/src/signities/pointer_router.dart:93:12)E/flatter(4428):#9 PointerRouter_调度事件路由。(软件包:flatter/src/signities/pointer_router.dart:138:9)E/flatter(4428):#10_LinkedHashMapMixin。forEach(dart:collection patch/compact_hash.dart:397:8)E/flatter(4428):#11点外部_dispatchEventToRoutes(包:flatter/src/signities/pointer_router.dart:136:18)E/flatter(4428):#12点路由器。路线(包:flift/src/signatures/pointer_router.dart:122:7)E/flift(4428):#13手势绑定。手风(套装:颤振/src/signatures/binding.dart:381:19)E/flatter(4428):#14手势绑定。dispatchEvent(包:flatter/src/signatures/binding.dart:361:22)E/flatter(4428):#15渲染器绑定。dispatchEvent(包:flatter/src/rendering/binding.dart:278:11)E/flatter(4428):#16个手势绑定_立即(包装:颤振/src/手势/绑定。省道:316:7)E/颤振(4428):#17手势绑定。手指头事件(包装:flatter/src/signatures/binding.dart:280:5)E/flatter(4428):#18手势绑定_flushPointerEventQueue(包装:flatter/src/signatures/binding.dart:238:7)E/flatter(4428):#19手势绑定_handlePointerDataPacket(包:flatter/src/signatures/binding.dart:221:7)E/flatter(4428):#20 RootRunnary(dart:async/zone.dart:1202:13)E/flatter(4428):#21 CustomZone。一元(dart:async/zone.dart:1097:19)E/flatter(4428):#22 34; CustomZone。runUnaryGuarded(dart:async/zone.dart:1002:7)E/flatter(4428):#23 _invoke1(dart:ui/hooks.dart:176:10)E/flatter(4428):#24
PlatformDispatcher_dispatchPointerDataPacket(dart:ui/platform\u dispatcher.dart:276:7)E/flatter(4428):\25
\u dispatchPointerDataPacket(dart:ui/hooks.dart:96:31)E/flatter(4428):

共有1个答案

鲜于玮
2023-03-14

你打错字了。使用“打印(e.message);”而不是“打印(如按摩);”在您的打印声明中:

catch(e){
        print(e.message);
      }
 类似资料:
  • 目前,我的Firebase仅激活了读取模式,如下面的警告消息所示: 我需要将一个子节点添加到具有许多子节点的地方,或者只编辑信息以创建新功能。然而,我不想以编程方式进行,因为我必须更改读取数据的方式,有没有办法使用控制台为具有大量子节点的地方添加子节点?

  • 我试图从获取列,并将其转换为。

  • 我尝试在Firebase Cloud函数中使用Cloud Vision API来OCR存储在Firebase存储中的图像。 我导入谷歌云视觉客户端库如下 然后我打电话 然而,我得到了一个错误 打字错误:视觉。detectText不是一个函数 最初我用 从这个例子中https://cloud.google.com/vision/docs/reference/libraries#client-libr

  • 《尘埃树》是一款以灰尘为主题的模组树游戏。游戏有合成、解谜等元素,汉化还在进行中。

  • 我是新来的火花...在阅读基本原理时,一些基本的东西我不清楚:

  • 然后我将Android应用程序添加到staging firebase项目中。我为staging firebase项目下载了google-services.json文件,并将其交换到Android/app目录中。目前,Android生产应用程序和staging应用程序之间的唯一区别是google-services.json文件。一旦我这样做了,firebase就不为分期应用程序工作了。活动用户没有反